Пример #1
0
        private void txtCusNumber_TextChanged(object sender, EventArgs e)
        {
            BUS_Customer busCus = new BUS_Customer();

            try
            {
                cus = busCus.searchPhone(txtCusPhone1.Text);
                if (cus != null)
                {
                    txtCusName.Text   = cus.cusName;
                    txtCusAdress.Text = cus.cusAddress;
                }
                else
                {
                    txtCusName.Text   = "";
                    txtCusAdress.Text = "";
                }
            }
            catch
            {
                txtCusName.Text   = "";
                txtCusAdress.Text = "";
                txtCusPhone1.Clear();
            }
        }
Пример #2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            int             count         = 0;
            BUS_Order       bus           = new BUS_Order();
            BUS_Orderdetail busOderDetail = new BUS_Orderdetail();
            BUS_Customer    busCus        = new BUS_Customer();
            string          valid         = checkConfirm();

            if (valid.Equals(""))
            {
                if (cus != null)
                {
                    string    cusphone      = cus.cusPhonenumber;
                    string    idEmp         = employee.Username;
                    long      totalPrice    = int.Parse(lblTotalPrice.Text);
                    int       totalQuantity = int.Parse(lblQuantity.Text);
                    DTO_Order order         = new DTO_Order(cusphone, idEmp, totalPrice, totalQuantity);
                    int       IDOrder       = bus.createOrder(order);

                    foreach (DTO_Product pro in listCart)
                    {
                        DTO_OrderDetail detail = new DTO_OrderDetail(IDOrder, pro.proID, pro.proPrice, pro.discount, pro.proQuantity);
                        int             counts = busOderDetail.createOrderDetail(detail);
                        count += counts;
                    }
                    showBill();
                    MessageBox.Show(count.ToString());
                }
                else
                {
                    string newCus   = txtCusName.Text;
                    string newPhone = txtCusPhone1.Text;
                    string newAdd   = txtCusAdress.Text;
                    cus = new DTO_Customer(newPhone, newCus, newAdd);
                    busCus.creatCustomer(cus);
                    string idEmp         = employee.Username;
                    int    totalQuantity = int.Parse(lblQuantity.Text);
                    long   totalPrice    = int.Parse(lblTotalPrice.Text);

                    DTO_Order order   = new DTO_Order(cus.cusPhonenumber, idEmp, totalPrice, totalQuantity);
                    int       IDOrder = bus.createOrder(order);

                    foreach (DTO_Product pro in listCart)
                    {
                        DTO_OrderDetail detail = new DTO_OrderDetail(IDOrder, pro.proID, pro.proPrice, pro.discount, pro.proQuantity);
                        int             counts = busOderDetail.createOrderDetail(detail);
                        count += counts;
                    }
                    MessageBox.Show(count.ToString());
                    showBill();
                }
                clear1();
                loadProduct();
            }
            else
            {
                MessageBox.Show(valid);
            }
        }
        private void btndelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xoá thật không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                BUS_Customer DL = new BUS_Customer();
                DTO_Customer DT = new DTO_Customer(Convert.ToInt32(txtmakh.Text));

                DL.DeleteCustomer(DT);
                dgvkh.DataSource = GetCustomer();

                MessageBox.Show(" BẠN ĐÃ XÓA KHÁCH HÀNG THÀNH CÔNG", " Xác nhận");
            }
        }
 private void btnTimKiemKH_Click(object sender, EventArgs e)
 {
     switch (typeCheck)
     {
     case 1:
     {
         DTO_Customer emp = new DTO_Customer(Convert.ToInt32(txtbtimkiemkh.Text));
         DataTable    dt  = new DataTable();
         BUS_Customer em  = new BUS_Customer();
         dt = em.SearchByMaKH(emp);
         dgvtimkiem.DataSource = dt;
         break;
     }
     }
 }
        private void btnedit_Click(object sender, EventArgs e)
        {
            {
                int      makh;
                string   hokh, tenkh, sdt, gioitinh, diachithuongtru, email;
                DateTime ngaysinh;

                makh = int.Parse(txtmakh.Text.Trim());

                hokh            = txthokh.Text.Trim();
                tenkh           = txttenkh.Text.Trim();
                gioitinh        = txtgioittinhkh.Text.Trim();
                sdt             = txtsdtkh.Text.Trim();
                ngaysinh        = Convert.ToDateTime(dtpngaysinhkh.Text.ToString());
                diachithuongtru = txtdiachickh.Text.Trim();
                email           = txtemailkh.Text.Trim();


                DTO_Customer emp = new DTO_Customer(makh, hokh, tenkh, gioitinh, sdt, ngaysinh, diachithuongtru, email);
                try
                {
                    int i = new BUS_Customer().UpdateCustomer(emp);
                    if (i == -2)
                    {
                        throw new Exception();
                    }
                    MessageBox.Show("ĐÃ SỬA THÀNH CÔNG", "Xác nhận");
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                dgvkh.DataSource = GetCustomer();
            }
        }
        private void btnadd_Click(object sender, EventArgs e)
        {
            int      pMaKH;
            string   pHoKH, pTenKH, pGioiTinh, pSDT, pDiaChiThuongTru, pEmail;
            DateTime pNgaySinh;

            pMaKH            = Convert.ToInt32(txtmakh.Text);
            pHoKH            = txthokh.Text.Trim();
            pTenKH           = txttenkh.Text.Trim();
            pGioiTinh        = txtgioittinhkh.Text.Trim();
            pSDT             = txtsdtkh.Text.Trim();
            pNgaySinh        = Convert.ToDateTime(dtpngaysinhkh.Text.ToString());
            pDiaChiThuongTru = txtdiachickh.Text.Trim();
            pEmail           = txtemailkh.Text.Trim();

            DTO_Customer emp = new DTO_Customer(pMaKH, pHoKH, pTenKH, pGioiTinh, pSDT, pNgaySinh, pDiaChiThuongTru, pEmail);

            try
            {
                int i = new BUS_Customer().AddCustomer(emp);
                if (i == -2)
                {
                    throw new Exception();
                }
                MessageBox.Show(" Bạn đã thêm thành công", " Xác nhận");
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            dgvkh.DataSource = GetCustomer();
        }