コード例 #1
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);
            }
        }
コード例 #2
0
        private void dgvOrder_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            BUS_Orderdetail busDetail   = new BUS_Orderdetail();
            DataGridViewRow selectedRow = dgvOrder.CurrentRow;
            string          id          = selectedRow.Cells[0].Value.ToString();

            txtIdOrder2.Text          = id;
            dgvOrderDetail.DataSource = busDetail.searchDetailByIdOrder(id);
            loadOrder();
        }
コード例 #3
0
        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);
            }
        }