コード例 #1
0
        public void Tables_CustomerRegisterTables_RelationshipTest()
        {
            BaseTableAdapter tableAdapter = new GenderTableAdapter();

            tableAdapter.Connection = ConnectionManager.Connection;
            Tables tables = new Tables();

            tableAdapter.Fill(tables.GenderDataTable);
            tableAdapter            = new ApppTprTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.ApppDataTable);
            tableAdapter            = new CustomerTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.CustomerDataTable);

            tableAdapter            = new RegisterTypeTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.RegisterTypeDataTable);
            tableAdapter            = new LandTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.LandDataTable);
            tableAdapter            = new WhyDeRegisterTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.WhyDeRegisterDataTable);

            tableAdapter            = new RegisterTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.RegisterDataTable);

            Assert.IsTrue(tables.RegisterDataTable.Rows.Count > 1);
        }
コード例 #2
0
        public void Tables_CustomerRegisterTables_Relationship_DeleteCascadTest()
        {
            ConnectionManager.SetConnection("Supervisor", "admin");
            BaseTableAdapter tableAdapter = new GenderTableAdapter();

            tableAdapter.Connection = ConnectionManager.Connection;
            Tables tables = new Tables();

            tableAdapter.Fill(tables.GenderDataTable);
            tableAdapter            = new ApppTprTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.ApppDataTable);
            tableAdapter            = new CustomerTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.CustomerDataTable);

            tableAdapter            = new RegisterTypeTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.RegisterTypeDataTable);
            tableAdapter            = new LandTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.LandDataTable);
            tableAdapter            = new WhyDeRegisterTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.WhyDeRegisterDataTable);

            tableAdapter            = new RegisterTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.RegisterDataTable);

            int countRows  = tables.RegisterDataTable.Rows.Count;
            int customerId = Int32.Parse(tables.RegisterDataTable.Rows[tables.RegisterDataTable.Rows.Count - 1]["CustomerID"].ToString());

            for (int i = 0; i < tables.CustomerDataTable.Rows.Count; i++)
            {
                if (Int32.Parse(tables.CustomerDataTable.Rows[i][0].ToString()) == customerId)
                {
                    tables.CustomerDataTable.Rows[i].Delete();
                    break;
                }
            }

            tableAdapter            = new CustomerTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            ((UpdateBaseTableAdapter)tableAdapter).Update(tables.CustomerDataTable);
            tableAdapter            = new RegisterTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.RegisterDataTable);
            Assert.IsTrue(countRows - tables.RegisterDataTable.Rows.Count >= 1);
        }