Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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;
        }