private void btnAdd_Click(object sender, EventArgs e)
        {
            if (ChechData_OrderDetail() == true)
            {
                if (Check_ProductExist() == true)
                {
                    DTO_OrderDetail dto_ordd = new DTO_OrderDetail(txtOrderID.Text, cboProductID.Text, int.Parse(numAmount.Value.ToString()), long.Parse(txtTotalAmount.Text));
                    if (bus_ordd.Add(dto_ordd))
                    {
                        MessageBox.Show("ADDING SUCCESS!", "ADD", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvOrderDetail.DataSource = bus_ordd.Display_ORDERDETAIL(txtOrderID.Text);

                        long totalprice = 0;
                        for (int i = 0; i < (dgvOrderDetail.Rows.Count) - 1; i++)
                        {
                            totalprice += long.Parse(dgvOrderDetail.Rows[i].Cells[6].Value.ToString());
                        }
                        lblTotalPrice.Text = totalprice.ToString();

                        numAmount.Value     = 0;
                        txtTotalAmount.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("ADDING FAIL!", "ADD", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("'    " + cboProductID.Text + "' already exists!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #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);
            }
        }
        public static int createOrderDetail(DTO_OrderDetail orderDetail)
        {
            SqlConnection cnn = DataProvider.ConnectData();
            var           cmd = new SqlCommand("createoderdetail", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@IDOrther", SqlDbType.Int).Value       = orderDetail.IDOrther;
            cmd.Parameters.Add("@IDProduct", SqlDbType.NVarChar).Value = orderDetail.IDProduct;
            cmd.Parameters.Add("@Price", SqlDbType.Float).Value        = orderDetail.Price;
            cmd.Parameters.Add("@Discount", SqlDbType.NVarChar).Value  = orderDetail.Discount;
            cmd.Parameters.Add("@Quantity", SqlDbType.Int).Value       = orderDetail.Quantity;
            int count = cmd.ExecuteNonQuery();

            return(count);
        }
Пример #4
0
 public bool Edit(DTO_OrderDetail dto_ordd)
 {
     return(dto_ordd.Edit());
 }
Пример #5
0
 public bool Add(DTO_OrderDetail dto_ordd)
 {
     return(dto_ordd.Add());
 }
Пример #6
0
 public int createOrderDetail(DTO_OrderDetail orderDetail)
 {
     return(DAO_Orderdetail.createOrderDetail(orderDetail));
 }