Beispiel #1
0
        public void Tables_CustomerAddressTables_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 AdminDivisionTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;

            tableAdapter.Fill(tables.AdminDivisionDataTable);
            tableAdapter            = new TypeStreetTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.TypeStreetDataTable);
            tableAdapter            = new AddressTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.AddressDataTable);

            Assert.IsTrue(tables.AddressDataTable.Rows.Count > 0);
        }
        public void Tables_AddNewCustomerAndAddressTest()
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            Tables           tables       = new Tables();
            BaseTableAdapter tableAdapter = new GenderTableAdapter();

            tableAdapter.Connection = connection;
            tableAdapter.Fill(tables.GenderDataTable);
            tableAdapter            = new ApppTprTableAdapter();
            tableAdapter.Connection = connection;
            tableAdapter.Fill(tables.ApppDataTable);
            tableAdapter            = new CustomerTableAdapter();
            tableAdapter.Connection = connection;
            tableAdapter.Fill(tables.CustomerDataTable);
            tableAdapter            = new AdminDivisionTableAdapter();
            tableAdapter.Connection = connection;
            tableAdapter.Fill(tables.AdminDivisionDataTable);
            tableAdapter            = new TypeStreetTableAdapter();
            tableAdapter.Connection = connection;
            tableAdapter.Fill(tables.TypeStreetDataTable);
            tableAdapter            = new AddressTableAdapter();
            tableAdapter.Connection = connection;
            tableAdapter.Fill(tables.AddressDataTable);

            DataRow newRow = tables.CustomerDataTable.NewRow();

            newRow["MedCard"]      = 123;
            newRow["CodeCustomer"] = 321;
            newRow["LastName"]     = "Bogodur";
            newRow["FirstName"]    = "Ivan";
            newRow["MiddleName"]   = "Bogodurovich";
            newRow["Birthday"]     = new DateTime(1970, 1, 1);
            newRow["Arch"]         = false;
            newRow["APPPTPRID"]    = tables.ApppDataTable.Rows[0]["APPPTPRID"];
            newRow["GenderID"]     = tables.GenderDataTable.Rows[0]["GenderID"];
            tables.CustomerDataTable.Rows.Add(newRow);
            int newCustomerId = (int)newRow["CustomerID"];

            newRow                    = tables.AddressDataTable.NewRow();
            newRow["City"]            = "Slavyansk";
            newRow["AdminDivisionID"] = tables.AdminDivisionDataTable.Rows[0]["AdminDivisionID"];;
            newRow["NameStreet"]      = "Lenina";
            newRow["NumberHouse"]     = "57";
            newRow["NumberApartment"] = "37";
            newRow["CustomerID"]      = newCustomerId;
            tables.AddressDataTable.Rows.Add(newRow);
            tables.DispancerDataSet.AcceptChanges();
            var ds    = tables.DispancerDataSet.GetChanges();
            int count = 0;

            if (ds != null)
            {
                count = ds.Tables.Count;
            }

            Assert.IsTrue(count == 0);
        }
Beispiel #3
0
        public void Tables_CustomerAddressTables_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 AdminDivisionTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.AdminDivisionDataTable);
            tableAdapter            = new TypeStreetTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.TypeStreetDataTable);
            tableAdapter            = new AddressTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.AddressDataTable);

            int countRows  = tables.AddressDataTable.Rows.Count;
            int customerId = Int32.Parse(tables.AddressDataTable.Rows[tables.AddressDataTable.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 AddressTableAdapter();
            tableAdapter.Connection = ConnectionManager.Connection;
            tableAdapter.Fill(tables.AddressDataTable);
            Assert.IsTrue(countRows - tables.AddressDataTable.Rows.Count >= 1);
        }
Beispiel #4
0
        public void Tables_CustomerAddressTables_TransactionTest()
        {
            SqlConnection connection = ConnectionManager.Connection;

            connection.Open();
            SqlTransaction   transaction  = connection.BeginTransaction();
            BaseTableAdapter tableAdapter = new GenderTableAdapter();

            tableAdapter.Connection  = connection;
            tableAdapter.Transaction = transaction;
            Tables tables = new Tables();

            tableAdapter.Fill(tables.GenderDataTable);
            tableAdapter             = new ApppTprTableAdapter();
            tableAdapter.Connection  = connection;
            tableAdapter.Transaction = transaction;
            tableAdapter.Fill(tables.ApppDataTable);
            tableAdapter             = new CustomerTableAdapter();
            tableAdapter.Connection  = connection;
            tableAdapter.Transaction = transaction;
            tableAdapter.Fill(tables.CustomerDataTable);

            tableAdapter             = new AdminDivisionTableAdapter();
            tableAdapter.Connection  = connection;
            tableAdapter.Transaction = transaction;

            tableAdapter.Fill(tables.AdminDivisionDataTable);
            tableAdapter             = new TypeStreetTableAdapter();
            tableAdapter.Connection  = connection;
            tableAdapter.Transaction = transaction;
            tableAdapter.Fill(tables.TypeStreetDataTable);
            tableAdapter             = new AddressTableAdapter();
            tableAdapter.Connection  = connection;
            tableAdapter.Transaction = transaction;
            tableAdapter.Fill(tables.AddressDataTable);
            transaction.Commit();
            Assert.IsTrue(tables.AddressDataTable.Rows.Count > 0);
        }
        protected BaseTableAdapter GetGlossary(string name)
        {
            BaseTableAdapter table = null;

            switch (name)
            {
            case "Address":
                table = new AddressTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Customer":
                table = new Accounting.DAL.TableAdapters.CustomerTableAdapter.CustomerTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Invalid":
                table = new InvalidBenefitsCategoryTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Register":
                table = new RegisterTableAdapter()
                {
                    Connection = _conn
                };
                break;
            }

            return(table);
        }