From 33574bc273f7540bbe3b38940e695df2bc080050 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 14 Jul 2023 20:54:28 +0000 Subject: [PATCH] --- utils/AyaImport/Form1.cs | 79 +++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/utils/AyaImport/Form1.cs b/utils/AyaImport/Form1.cs index dc1de0c..2fba544 100644 --- a/utils/AyaImport/Form1.cs +++ b/utils/AyaImport/Form1.cs @@ -416,10 +416,9 @@ namespace AyaImport { #if(DEBUG) #if(ATTEMPT_UPGRADE_FROM_142) - //cmd.CommandText = ("update blah set blah = blah"); - //cmd.ExecuteNonQuery(); + //NOTE: this will auto update it the moment you select the source DB and if all goes well then you can import. 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 @@ -5413,51 +5412,57 @@ namespace AyaImport case 146://changed to 147 on june 21th 2001 various updates { - + //set all blank company fields to last, first names - - 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); - - 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] " + //2023-07-14 just to ensure this works I append the record ID to ensure uniqueness to avoid the below rigamarole + executeQuery("UPDATE clients SET clients.company = [last] & \", \" & [first] & \" \" & [id] " + "WHERE (((clients.company) Is Null));"); - //rs->Close(); - } - else - { + //***********2023 ORIGINAL BLOCK I COMMENTED OUT + //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( - "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" + //OleDbDataReader rdr; + //rdr = cmdr.ExecuteReader(); - + "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" + ////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));"); - + "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."); + // //rs->Close(); + + //} + //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); - //stop from doing anything further - //buptodate=true; - //break; + // //m_pApp->ShowStuff(strData); + // //stop from doing anything further + // //buptodate=true; + // //break; - } + //} + //************************************************ //---------------------------------------------------------------------------- //Performance boost - new indexes