示例#1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            int id = 0;

            Int32.TryParse(txtCustomerIDToSearch.Text, out id);
            if (id == 0)
            {
                MessageBox.Show("Invalid ID");
                return;
            }
            else
            {
                CustomerDAL dal = new CustomerDAL();
                var         obj = dal.GetCustomerByID(id);
                if (obj != null)
                {
                    txtCustomerID.Text = obj.CustomerID.ToString();
                    txtName.Text       = obj.Name;
                    txtAddress.Text    = obj.Address;
                }
                else
                {
                    MessageBox.Show("Invalid ID");
                }
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CustomerDTO dto = new CustomerDTO();
            //Get value from ID textbox
            int id = 0;

            Int32.TryParse(txtCustomerID.Text, out id);

            dto.CustomerID = id;
            dto.Name       = txtName.Text;
            dto.Address    = txtAddress.Text;

            CustomerDAL dal = new CustomerDAL();

            if (id == 0) //Insert Case
            {
                dal.SaveCustomer(dto);
            }
            else //update case
            {
                dal.UpdateCustomer2(dto);
            }

            MessageBox.Show("Record is saved!");
        }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            CustomerDAL dal  = new CustomerDAL();
            var         list = dal.GetAllCustomers();

            foreach (var cust in list)
            {
                var accounts = cust.Accounts.ToList();
            }
        }
示例#4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int id = 0;

            Int32.TryParse(txtCustomerIDToSearch.Text, out id);
            if (id == 0)
            {
                MessageBox.Show("Invalid ID");
                return;
            }
            else
            {
                CustomerDAL dal = new CustomerDAL();
                dal.DeleteCustomer2(id);
                MessageBox.Show("Record deleted!");
            }
        }
示例#5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CustomerDTO dto = new CustomerDTO();
            //Get value from ID textbox
            int id = 0;

            Int32.TryParse(txtCustomerID.Text, out id);

            dto.CustomerID = id;
            dto.Name       = txtName.Text;
            dto.Address    = txtAddress.Text;

            var context = new ValidationContext(dto, serviceProvider: null, items: null);
            var results = new List <ValidationResult>();
            var isValid = Validator.TryValidateObject(dto, context, results, true);

            if (!isValid)
            {
                foreach (var validationResult in results)
                {
                    Console.WriteLine(validationResult.ErrorMessage);
                }
            }


            CustomerDAL dal = new CustomerDAL();

            if (id == 0) //Insert Case
            {
                dal.SaveCustomer(dto);
            }
            else //update case
            {
                dal.UpdateCustomer2(dto);
            }

            MessageBox.Show("Record is saved!");
        }
示例#6
0
        private void button1_Click(object sender, EventArgs e)
        {
            CustomerDTO dto = new CustomerDTO();

            dto.Name     = "Bilal";
            dto.Address  = "Lahore";
            dto.Accounts = new List <CustAccountsDTO>();

            dto.Accounts.Add(new CustAccountsDTO()
            {
                BankName      = "Alfalah",
                AccountNumber = "12345"
            });
            dto.Accounts.Add(new CustAccountsDTO()
            {
                BankName      = "Habib Bank",
                AccountNumber = "1234557"
            });

            CustomerDAL dal = new CustomerDAL();

            dal.SaveCustomer(dto);
        }
示例#7
0
 private void button3_Click(object sender, EventArgs e)
 {
     CustomerDAL dal  = new CustomerDAL();
     var         list = dal.GetAllCustomersExplicitly();
 }
示例#8
0
 private void button4_Click(object sender, EventArgs e)
 {
     CustomerDAL dal  = new CustomerDAL();
     var         list = dal.GetCustAccount_SP();
 }