This commit is contained in:
2023-07-14 20:54:28 +00:00
parent d21c88da53
commit 33574bc273

View File

@@ -416,10 +416,9 @@ namespace AyaImport
{ {
#if(DEBUG) #if(DEBUG)
#if(ATTEMPT_UPGRADE_FROM_142) #if(ATTEMPT_UPGRADE_FROM_142)
//cmd.CommandText = ("update blah set blah = blah"); //NOTE: this will auto update it the moment you select the source DB and if all goes well then you can import.
//cmd.ExecuteNonQuery();
UpdateCEDatabaseSchema.go(conn, nVersion); UpdateCEDatabaseSchema.go(conn, nVersion);
nVersion = 171;//if this update works then the version is now 171 nVersion = 171;//if this update works then the version is now 171 SET A BREAKPOINT HERE TO SEE IF IT WORKED OR WHATEVER
#endif #endif
#endif #endif
@@ -5413,51 +5412,57 @@ namespace AyaImport
case 146://changed to 147 on june 21th 2001 various updates case 146://changed to 147 on june 21th 2001 various updates
{ {
//set all blank company fields to last, first names //set all blank company fields to last, first names
//2023-07-14 just to ensure this works I append the record ID to ensure uniqueness to avoid the below rigamarole
OleDbCommand cmdr = new OleDbCommand("SELECT clients.last, clients.first, clients.bizphone FROM clients " executeQuery("UPDATE clients SET clients.company = [last] & \", \" & [first] & \" \" & [id] "
+ "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) "
+ "ORDER BY clients.last;", conn);
OleDbDataReader rdr;
rdr = cmdr.ExecuteReader();
//rs->QueryReadOnly("SELECT clients.last, clients.first, clients.bizphone FROM clients "
// "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) "
// "ORDER BY clients.last;");
//if(rs->IsEmpty())
if (!rdr.Read())//meaning none
{
executeQuery("UPDATE clients SET clients.company = [last] & \", \" & [first] "
+ "WHERE (((clients.company) Is Null));"); + "WHERE (((clients.company) Is Null));");
//rs->Close();
} //***********2023 ORIGINAL BLOCK I COMMENTED OUT
else //OleDbCommand cmdr = new OleDbCommand("SELECT clients.last, clients.first, clients.bizphone FROM clients "
{ // + "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) "
// + "ORDER BY clients.last;", conn);
throw new Exception( //OleDbDataReader rdr;
"Warning: Due to a change in the clients table in the database\r\n" //rdr = cmdr.ExecuteReader();
+ "this update needs to move the contact first and last names to the former \r\n"
+ "\"Company\" field which is now the single client field.\r\n\r\n"
+ "Your help is required to correct a problem before the update can finish:\r\n" ////rs->QueryReadOnly("SELECT clients.last, clients.first, clients.bizphone FROM clients "
+ "You have duplicate non-company clients and need to change them in the clients screen.\r\n\r\n" //// "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) "
//// "ORDER BY clients.last;");
////if(rs->IsEmpty())
//if (!rdr.Read())//meaning none
//{
// executeQuery("UPDATE clients SET clients.company = [last] & \", \" & [first] "
// + "WHERE (((clients.company) Is Null));");
+ "When this update completes and returns you to AyaNova, \r\n" // //rs->Close();
+ "go directly to the client screen (Options->Edit->Clients) where you will be given\r\n"
+ "more instructions on fixing the duplicate client names."); //}
//else
//{
// throw new Exception(
// "Warning: Due to a change in the clients table in the database\r\n"
// + "this update needs to move the contact first and last names to the former \r\n"
// + "\"Company\" field which is now the single client field.\r\n\r\n"
// + "Your help is required to correct a problem before the update can finish:\r\n"
// + "You have duplicate non-company clients and need to change them in the clients screen.\r\n\r\n"
// + "When this update completes and returns you to AyaNova, \r\n"
// + "go directly to the client screen (Options->Edit->Clients) where you will be given\r\n"
// + "more instructions on fixing the duplicate client names.");
//m_pApp->ShowStuff(strData); // //m_pApp->ShowStuff(strData);
//stop from doing anything further // //stop from doing anything further
//buptodate=true; // //buptodate=true;
//break; // //break;
} //}
//************************************************
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//Performance boost - new indexes //Performance boost - new indexes