예제 #1
0
        public void ThanhToan()
        {
            CBill SBill = new CBill();

            SBill.UpdateBill(ID_bill, ID_Employee, DateTime.Now, Total, "Yes");
            them  = true;
            Total = 0;
            Click = true;
        }
예제 #2
0
 void LoadAmount(List <int> list)
 {
     for (int i = 0; i < listFood.Count; i++)
     {
         list.Add(0);
     }
     if (!them)
     {
         CBill SBill = new CBill();
         List <GetDetailBill_Result> listDetailBills = new List <GetDetailBill_Result>();
         listDetailBills = SBill.GetDetailBill(ID_bill);
         for (int i = 0; i < listDetailBills.Count; i++)
         {
             for (int j = 0; j < list.Count; j++)
             {
                 if (listFood[j].ID_Food == listDetailBills[i].ID_Food)
                 {
                     list[j] = listDetailBills[i].Amount.Value;//////
                 }
             }
         }
     }
 }
예제 #3
0
        public bool HuyBan()
        {
            List <int> list_ID = new List <int>();

            for (int i = 0; i < listFood.Count; i++)
            {
                list_ID.Add(listFood[i].ID_Food);
            }
            FCancelBill Cancel = new FCancelBill(ID_bill, list_ID, ID_Employee, listCount);

            Cancel.ShowDialog();
            if (Cancel.Status)
            {
                Click = true;
                CBill SBill = new CBill();
                SBill.UpdateBill(ID_bill, ID_Employee, DateTime.Now, 0, "Yes");
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        public void CreateFoodbtn(Panel Order)
        {
            CBill SBill = new CBill();

            them = SBill.GetID_Bill(location, ref ID_bill);
            CFood sFood = new CFood();
            List <GetFood_Result> dtFood = new List <GetFood_Result>();

            dtFood   = sFood.GetFood("All", "All", "Yes");
            listFood = dtFood;

            if (them == false)
            {
                LoadAmount(listCount);
            }
            else
            {
                for (int i = 0; i < dtFood.Count; i++)
                {
                    listCount.Add(0);
                }
            }
            CreateUser(Order);

            lb1 = new Label()
            {
                Location = new Point(20, 220)
            };
            lb1.AutoSize = true;
            this.Bill.Controls.Add(lb1);
            if (them == false)
            {
                load();
            }
            LoadAmount(OldListCount);
        }
예제 #5
0
        public void OrderFood()
        {
            CBill SBill = new CBill();

            try
            {
                if (them)
                {
                    ID_bill = SBill.InsertBill(ID_Employee, DateTime.Now.ToString(), Total, location);
                    SBill.InserDetailBill(ID_bill, listFood, listCount, ID_Employee);
                    MessageBox.Show("Order thành công");
                    OldListCount = new List <int>();
                    LoadAmount(OldListCount);
                    Click = true;
                    them  = false;
                }
                else
                {
                    List <GetDetailBill_Result> dtDetailBill = new List <GetDetailBill_Result>();
                    dtDetailBill = SBill.GetDetailBill(ID_bill);
                    FCancelBill Cancel;
                    bool        chinhSua    = false;
                    bool        _continue   = true;
                    List <int>  list_Amount = new List <int>();
                    for (int i = 0; i < listFood.Count; i++)
                    {
                        int t = OldListCount[i] - listCount[i];
                        if (t > 0)
                        {
                            list_Amount.Add(t);
                        }
                        else
                        {
                            list_Amount.Add(0);
                        }
                        if (listCount[i] < OldListCount[i])
                        {
                            chinhSua = true;
                        }
                    }
                    if (chinhSua)
                    {
                        string warning = "Chắc xóa các món này không??\n Việc này cần quản lý xác nhận!\n";
                        for (int i = 0; i < list_Amount.Count; i++)
                        {
                            if (list_Amount[i] > 0)
                            {
                                warning = warning + listFood[i].Name + "   " + list_Amount[i].ToString() + "\n";
                            }
                        }
                        DialogResult traloi;
                        traloi = MessageBox.Show(warning, "Trả lời",
                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (traloi == DialogResult.Yes)
                        {
                            List <int> list_ID = new List <int>();

                            for (int i = 0; i < listFood.Count; i++)
                            {
                                list_ID.Add(listFood[i].ID_Food);
                            }
                            Cancel = new FCancelBill(ID_bill, list_ID, ID_Employee, list_Amount);
                            Cancel.ShowDialog();
                            if (Cancel.Status == false || traloi == DialogResult.No)
                            {
                                _continue = false;
                            }
                        }
                        else
                        {
                            _continue = false;
                        }
                    }
                    if (_continue)
                    {
                        if (Total != 0)
                        {
                            SBill.UpdateBill(ID_bill, ID_Employee, DateTime.Now, Total, "No");
                            for (int i = 0; i < listFood.Count; i++)
                            {
                                if (listCount[i] > 0)
                                {
                                    SBill.ProInsertOrUpdateDTBill(ID_bill, listFood[i].ID_Food, listCount[i], listFood[i].Sale.Value, listFood[i].Price.Value, ID_Employee);
                                }
                                else
                                {
                                    for (int j = 0; j < dtDetailBill.Count; j++)
                                    {
                                        if (listFood[i].ID_Food == dtDetailBill[j].ID_Food && dtDetailBill[j].Amount > 0)
                                        {
                                            SBill.DeleteDetailBill(ID_bill, listFood[i].ID_Food);
                                        }
                                    }
                                }
                            }
                            MessageBox.Show("Chỉnh sửa hóa đơn thành công");
                            OldListCount = new List <int>();
                            LoadAmount(OldListCount);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("vui lòng thử lại");
            }
            them = false;
        }