Example #1
0
        static void TestDBI_T_strength_T5()
        {
            Console.WriteLine("  --START: TestDBI_T_strength_T5");

            //Construct a brand new myTable in RAM
            SQLServerDB.strength_Table myTable = new SQLServerDB.strength_Table();
            myTable.itemList = new List <strength>()
            {
                //strength(String val_notes, String val_processArea, String val_specificGoal, String val_specificPractice, String val_genericGoal, String val_genericPractice,   int val_projectId)
                new strength("notes_1", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 404),
                new strength("notes_2", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 404),
                new strength("notes_3", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 404),
                new strength("notes_4", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 404),
                new strength("notes_5", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 404)
            };
            int iRowsStart = myTable.itemList.Count;

            //Count SQLServerDB strength table rows before clearing
            int iRows1 = myTable.CountRows();

            Console.WriteLine("myTable.CountRows = " + iRows1.ToString());

            myTable.Clear_Database_Table();
            int iRows2 = myTable.CountRows();

            if (iRows2 != 0)
            {
                Console.WriteLine("Error! iRows2=" + iRows2 + ".  After Clear_Database_Table should be zero");
            }

            myTable.WriteItemListToDatabase();

            int iRows3 = myTable.CountRows();

            if (iRows3 != iRowsStart)
            {
                Console.WriteLine("Error! iRows3=" + iRows3 + ".  After WriteItemListToDatabase should be " + iRowsStart);
            }
            else
            {
                Console.WriteLine("OK. CountRows=" + iRows3 + " After WriteItemListToDatabase");
            }

            Util.pause("examine table content with SSMS");

            Util.pause("before table query by projectID");
            int iProjectCount_404 = myTable.CountRows_By_projectId(404);

            if (iProjectCount_404 != iRowsStart)
            {
                Console.WriteLine("ERROR.  iProjectCount_404=" + iProjectCount_404 + ". Expected " + iRowsStart);
            }
            else
            {
                Console.WriteLine("OK. CountRows=" + iProjectCount_404 + " After WriteItemListToDatabase");
            }
            Util.pause();

            Console.WriteLine("  --DONE: TestDBI_T_strength_T5");
        }
Example #2
0
        }//TestDBI_T_strength_Read_from_DB

        /// <summary>
        /// TestDBI_T_strength_T3 -  clear the SQLServer strength table, write some demo data to SQLServer DB,
        /// query the affirmatin table by Project ID,
        /// </summary>
        static void TestDBI_T_strength_T3()
        {
            Console.WriteLine("  --START: TestDBI_T_strength_T3");

            //Construct myTable in RAM
            SQLServerDB.strength_Table myTable = new SQLServerDB.strength_Table();

            //put demo records into myTable
            for (int i = 1; i < 10; i++)
            {
                SQLServerDB.strength sItem = new SQLServerDB.strength();
                sItem.ID               = i;
                sItem.notes            = "aff_Name_" + i.ToString();
                sItem.processArea      = "aff_Type_" + i.ToString();
                sItem.specificGoal     = "aff_specificGoal_" + i.ToString();
                sItem.specificPractice = "aff_specificPractice_" + i.ToString();
                sItem.genericGoal      = "aff_genericGoal_" + i.ToString();
                sItem.genericPractice  = "aff_genericPractice_" + i.ToString();
                sItem.projectId        = i;

                myTable.itemList.Add(sItem);
            }

            //Count SQLServerDB strength 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();

            int iSeek_ProjectID = 3;

            Console.WriteLine("seek item:  iSeek_ProjectID= " + iSeek_ProjectID);
            myTable.ReadItemListFromDatabase_ByProjectID(iSeek_ProjectID);

            Console.WriteLine("SEEK items found: myTable.itemList.Count =" + myTable.itemList.Count.ToString());

            SQLServerDB.strength strengthItem = myTable.itemList[0];
            strengthItem.Show();

            Util.pause();

            Console.WriteLine("  --DONE: TestDBI_T_strength_T3");
        }
Example #3
0
        /// <summary>
        /// TestDBI_T_strength_T4 --
        /// </summary>
        static void TestDBI_T_strength_T4()
        {
            Console.WriteLine("  --START: TestDBI_T_strength_T4");

            //Construct a brand new myTable in RAM
            SQLServerDB.strength_Table myTable = new SQLServerDB.strength_Table();
            myTable.itemList = new List <strength>()
            {
                //strength(String val_notes, String val_processArea, String val_specificGoal, String val_specificPractice, String val_genericGoal, String val_genericPractice,   int val_projectId)
                new strength("notes_1", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 1),
                new strength("notes_2", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 2),
                new strength("notes_3", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 3),
                new strength("notes_4", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 4),
                new strength("notes_5", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 5)
            };
            int iRowsStart = myTable.itemList.Count;

            myTable.Clear_Database_Table();
            int iRows1 = myTable.CountRows();

            if (iRows1 != iRowsStart)
            {
                Console.WriteLine("ERR:  iRows should be zero after Clear_Database_Table");
            }
            Util.pause();

            myTable.WriteItemListToDatabase();
            int iRows2 = myTable.CountRows();

            if (iRows2 != iRowsStart)
            {
                Console.WriteLine("ERR: iRows2 should equal iRowsStart!  iRows2=" + iRows2);
            }
            else
            {
                Console.WriteLine("OK");
            }

            //Construct a brand new myTable in RAM
            SQLServerDB.strength_Table myTable2 = new SQLServerDB.strength_Table();
            myTable2.itemList = new List <strength>()
            {
                //strength(String val_notes, String val_processArea, String val_specificGoal, String val_specificPractice, String val_genericGoal, String val_genericPractice,   int val_projectId)
                new strength("notes_1A", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 1),
                new strength("notes_2B", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 2),
                new strength("notes_3", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 3),
                new strength("notes_4D", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 4),
                new strength("notes_5E", "pa_1", "sg_1", "sp_1", "gg_1", "gp_1", 5)
            };

            Console.WriteLine("---update the table");

            Console.WriteLine("BEFORE the table update");
            myTable2.Show();
            Util.pause("ready to update");

            myTable.UpdateItemListToDatabase();
            Console.WriteLine("AFTER the table update");
            myTable2.Show();
            Util.pause();

            Console.WriteLine("  --DONE: TestDBI_T_strength_T4");
        }