public int insertBillInfo(TableFoodDTO table, string food, int quantity)
        {
            bool    check   = false;
            BillBUS busBill = new BillBUS();
            int     idBill  = busBill.getBillUnCheckoutByNameTable(table.Name);

            if (idBill == 0)
            {
                idBill = busBill.getMaxIDBill() + 1;
                DateTime currentDate = DateTime.Now;
                string   nameTable   = table.Name;
                string   status      = "Chưa thanh toán";
                string   staff       = null;
                BillDTO  dtoBill     = new BillDTO(idBill, currentDate, nameTable, status, staff);
                check = busBill.insertBill(dtoBill);
                if (check)
                {
                    int         idBillInfo  = dao.getMaxIDBillInfo() + 1;
                    BillInfoDTO dtoBillInfo = new BillInfoDTO(idBillInfo, idBill, food, quantity);
                    check = dao.insertBillInfo(dtoBillInfo);
                    if (check)
                    {
                        string       statusTable = "Có người";
                        TableFoodBUS busTable    = new TableFoodBUS();
                        check = busTable.updateStatusTable(nameTable, statusTable);
                    }
                }
            }
            else
            {
                BillInfoDTO dtoBillInfo = dao.checkExistFoodInBill(idBill, food);
                if (dtoBillInfo != null)
                {
                    check = dao.updateQuantityBillInfo(dtoBillInfo.Id, quantity + dtoBillInfo.Quantity);
                }
                else
                {
                    int idBillInfo = dao.getMaxIDBillInfo() + 1;
                    dtoBillInfo = new BillInfoDTO(idBillInfo, idBill, food, quantity);
                    check       = dao.insertBillInfo(dtoBillInfo);
                }
            }

            if (!check)
            {
                idBill = -1;
            }


            return(idBill);
        }
示例#2
0
        public bool checkoutBill(TableFoodDTO table, string staff, int total)
        {
            BillBUS  busBill      = new BillBUS();
            int      idBill       = busBill.getBillUnCheckoutByNameTable(table.Name);
            DateTime checkOutDate = DateTime.Now;
            string   status       = "Đã thanh toán";
            bool     check        = dao.checkoutBill(idBill, staff, total, status, checkOutDate);

            if (check)
            {
                TableFoodBUS busTable = new TableFoodBUS();
                check = busTable.updateStatusTable(table.Name, "Trống");
            }
            return(check);
        }