Beispiel #1
0
        public List <DTO_Order> GetMenu()
        {
            List <DTO_Order> list = new List <DTO_Order>();
            int     mamonnuoc;
            decimal giatien;
            string  tenmonnuoc, donvi;

            //dp.Connect();
            try
            {
                string        sql = "SELECT * FROM MonNuoc";
                SqlDataReader dr  = dp.ExecuteReader(sql);
                while (dr.Read())
                {
                    mamonnuoc  = dr.GetInt32(0);
                    tenmonnuoc = dr.GetString(1);
                    giatien    = dr.GetDecimal(2);
                    donvi      = dr.GetString(3);

                    DTO_Order emp = new DTO_Order(mamonnuoc, tenmonnuoc, giatien, donvi);
                    list.Add(emp);
                }
                dr.Close();
                return(list);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                dp.DisConnect();
            }
        }
        private void btnSaveOrder_Click(object sender, EventArgs e)
        {
            if (CheckData_Order() == true)
            {
                DialogResult dialogResult = MessageBox.Show("Saving and print bill, are you sure?", "SAVE AND PRINT", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dialogResult == DialogResult.OK)
                {
                    DTO_Order dto_ord = new DTO_Order(txtOrderID.Text, cboBookingID.Text, txtCustomerID.Text, txtVet.Text, txtPetID.Text, cboEmployeeID.Text, OrderDate.Value.ToString(), long.Parse(lblTotalPrice.Text));
                    if (bus_ord.Save(dto_ord))
                    {
                        MessageBox.Show("SAVE SUCCESS!", "NOTIFICATON", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        printPreviewDialog.Document = printDocument;
                        printPreviewDialog.ShowDialog();
                        printDocument.Print(); // In hóa đơn

                        Load_cboBookingID();
                        dgvOrderDetail.DataSource = bus_ordd.Refresh_OrderDetail_Empty(); // Tạo mới lại bảng Chi tiết hóa đơn rỗng
                        ResetOrder();
                    }
                    else
                    {
                        MessageBox.Show("SAVE FAIL!", "NOTIFICATON", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                }
            }
        }
        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);
            }
        }
Beispiel #4
0
        public void XoaMon(DTO_Order dm, int maban)
        {
            SqlConnection cnn = dp.getConnect();

            dp.Connect();//ham nay de ket noi thay thi cnn.open();
            string     XoaMon = "DELETE FROM HoaDon WHERE MaMonNuoc = '" + dm.MaMonNuoc + "'" + "and MaBan ='" + maban + "'";
            SqlCommand cmd    = new SqlCommand(XoaMon, cnn);

            cmd.ExecuteNonQuery();
        }
        public static int createOrder(DTO_Order order)
        {
            SqlConnection cnn = DataProvider.ConnectData();
            var           cmd = new SqlCommand("createordert", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@CusPhone", SqlDbType.Char).Value       = order.cusPhone;
            cmd.Parameters.Add("@IdEmployee", SqlDbType.NVarChar).Value = order.idEmp;
            cmd.Parameters.Add("@PriceFinal", SqlDbType.Float).Value    = order.total;
            cmd.Parameters.Add("@Quantity", SqlDbType.Int).Value        = order.quantity;
            return((int)cmd.ExecuteScalar());
        }
        public async Task GetOrderItemsByOrderID(DTO_Order token)
        {
            try
            {
                var response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "GetOrderItemsByOrderID"),
                                                            token);

                response.EnsureSuccessStatusCode();
                OrderItemsList = await response.Content.ReadAsAsync <List <DTO_OrderItem> >();
            }
            catch (Exception ex)
            {
            }
        }
        public async Task AddOrder(DTO_Order token)
        {
            try
            {
                var response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "AddOrder"),
                                                            token);

                response.EnsureSuccessStatusCode();
                Order = await response.Content.ReadAsAsync <DTO_Order>();
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }
Beispiel #8
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");
            }
        }
        public void XoaMon(DTO_Order ma, int maban)
        {
            DAO_Order mon = new DAO_Order();

            mon.XoaMon(ma, maban);
        }
Beispiel #10
0
 public bool Save(DTO_Order dto_ord)
 {
     return(dto_ord.Save());
 }
 public int createOrder(DTO_Order order)
 {
     return(DAO_Order.createOrder(order));
 }