}//TestDBI_T_affirmation_note_Write_to_DB //------------------------------------------------------------------------------------------- static void TestDBI_T_affirmation_note_Read_from_DB() { Console.WriteLine(" --START: TestDBI_T_affirmation_note_Read_from_DB"); SQLServerDB.affirmation_note_Table myTable = new SQLServerDB.affirmation_note_Table(); int iRows = myTable.CountRows(); Console.WriteLine("myTable.CountRows = " + iRows.ToString()); Console.WriteLine("Fill the table in RAM from the SQLServer Database table"); myTable.ReadItemListFromDatabase(); myTable.Show(); if (myTable.itemList.Count != iRows) { Console.WriteLine("Error. myTable.itemList.Count != myTable.CountRows." + " should be the same ReadItemListFromDatabase ()"); } else { Console.WriteLine("OK. After ReadItemListFromDatabase()"); } Util.pause(); Console.WriteLine(" --DONE: TestDBI_T_affirmation_note_Read_from_DB"); }//TestDBI_T_affirmation_note_Read_from_DB
//------------------------------------------------------------------------------------------- static void TestDBI_T_affirmation_note_Write_to_DB() { Console.WriteLine(" --START: TestDBI_T_affirmation_note_Write_to_DB"); SQLServerDB.affirmation_note_Table myTable = new SQLServerDB.affirmation_note_Table(); myTable.itemList = make_affirmation_note_list_1(); int iRowsStart = myTable.itemList.Count; myTable.Show(); Util.pause(); Console.WriteLine(" --before clear SQLServer database table"); Util.pause(); myTable.Clear_Database_Table(); int iRows2 = myTable.CountRows(); if (iRows2 != 0) { Util.pause("Error. iRows=" + iRows2 + " should be zero after Clear_Database_Table()"); } else { Util.pause("OK. After Clear_Database_Table()"); } Console.WriteLine("Write the table from RAM the SQLServer Database table"); myTable.WriteItemListToDatabase(); int iRows3 = myTable.CountRows(); if (iRows3 != iRowsStart) { Util.pause("Error. iRows3=" + iRows3 + " should be " + iRowsStart + " after WriteItemListToDatabase"); } else { Util.pause("OK. After WriteItemListToDatabase()"); } Console.WriteLine(" --after writing to the SQLServer database table. examine the table using SSMS"); Util.pause("visually inspect via SSMS?"); Console.WriteLine(" --DONE: TestDBI_T_affirmation_note_Write_to_DB"); }//TestDBI_T_affirmation_note_Write_to_DB
}//TestDBI_T_affirmation_note_Read_from_DB //------------------------------------------------------------------------------------------- static void TestDBI_T_affirmation_note_T3() { Console.WriteLine(" --START: TestDBI_T_affirmation_note_T3"); //Construct myTable in RAM SQLServerDB.affirmation_note_Table myTable = new SQLServerDB.affirmation_note_Table(); //put demo records into myTable for (int i = 1; i < 10; i++) { SQLServerDB.affirmation_note affItem = new SQLServerDB.affirmation_note(); affItem.affirmationId = i; affItem.notes = "aff_note_" + i.ToString(); myTable.itemList.Add(affItem); } //Count SQLServerDB affirmation table rows before clearing int iRows = myTable.CountRows(); Console.WriteLine("myTable.CountRows = " + iRows.ToString()); Console.WriteLine(" --before clear SQLServer database table"); Util.pause(); myTable.Clear_Database_Table(); int iRows2 = myTable.CountRows(); Console.WriteLine("myTable.CountRows = " + iRows2.ToString()); Util.pause(); myTable.WriteItemListToDatabase(); Console.WriteLine("after writing to SQLServerDB"); Util.pause(); int iRows3 = myTable.CountRows(); Console.WriteLine("myTable.CountRows = " + iRows3.ToString()); Util.pause(); //put demo records into myTable myTable.itemList.Clear(); for (int i = 1; i < 10; i++) { SQLServerDB.affirmation_note affItem = new SQLServerDB.affirmation_note(); affItem.affirmationId = i; affItem.notes = "aff_note_" + i.ToString() + "_Rev_A"; myTable.itemList.Add(affItem); } myTable.Show(); Util.pause("--BEFORE the update, showing the planned updates in myTable.itemList"); myTable.UpdateItemListToDatabase(); Util.pause("-- AFTER the update, examine the affirmation_note Table using SSMS"); myTable.Clear_Database_Table_By_AffirmationID(2); myTable.Clear_Database_Table_By_AffirmationID(4); myTable.Clear_Database_Table_By_AffirmationID(6); Util.pause("-- AFTER Clear_Database_Table_By_AffirmationID {2,4,6} using SSMS"); Console.WriteLine(" --DONE: TestDBI_T_affirmation_note_T3"); }//TestDBI_T_affirmation_note_T3