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 textBox1_TextChanged(object sender, EventArgs e)
        {
            BUS_Order       busOrder  = new BUS_Order();
            BUS_Orderdetail busDetail = new BUS_Orderdetail();

            if (cbSearch2.SelectedIndex == 0)
            {
                string id = txtSearch2.Text;
                dgvOrder.DataSource = busOrder.searchOrderByIdOrder(id);
            }
            else
            {
                string phone = txtSearch2.Text;
                dgvOrder.DataSource = busOrder.searchOrderByPhone(phone);
            }
        }
Beispiel #3
0
        private void btnXoaMon_Click(object sender, EventArgs e)
        {
            try
            {
                int       index = dgvMonvaBan.CurrentRow.Index;
                int       maban = Convert.ToInt32(dgvMonvaBan.Rows[index].Cells[2].Value.ToString().Trim());
                DTO_Order monan = new DTO_Order(Convert.ToInt32(txtbXoaMon.Text));

                BUS_Order ma = new BUS_Order();
                ma.XoaMon(monan, maban);

                dgvMonvaBan.DataSource = GetInvoice_GUI();
                dgvMonvaBan.DataSource = GetMaBan_GUI11(maban);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("FAIL");
            }
        }