private void BtnCheckOut_Click(object sender, EventArgs e)
        {
            TableDTO table = lsvBill.Tag as TableDTO;

            if (table == null)
            {
                return;
            }
            int    idBill          = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);
            int    discount        = (int)nmDisCount.Value;
            double totalPrice      = double.Parse(txtTottalPrice.Text, NumberStyles.Currency, new CultureInfo("vi-VN"));
            double finalTotalPrice = totalPrice - (totalPrice / 100) * discount;

            if (idBill != -1)
            {
                if (MessageBox.Show(string.Format("Bạn có chắc thanh toán hóa đơn cho bàn {0}\nTổng tiền - (Tổng tiền / 100) x Giảm giá\n=> {1} - ({1} / 100) x {2} = {3}", table.Name, totalPrice, discount, finalTotalPrice), "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    BillDAO.Instance.CheckOut(idBill, discount, (float)finalTotalPrice);
                    Form Bill = new fBill(idBill, accountlogin.DisplayName, totalPrice, discount, finalTotalPrice);
                    Bill.Show();
                    LoadTable();
                    ShowBill(table.ID);
                }
            }
        }
        private void BtnAddFood_Click(object sender, EventArgs e)
        {
            TableDTO table  = lsvBill.Tag as TableDTO;
            int      idBill = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);

            if (cbbFood.SelectedIndex == -1)
            {
                MessageBox.Show("Vui lòng chọn món!", "Thông báo", MessageBoxButtons.OK);
            }
            else
            {
                int idFood = (cbbFood.SelectedItem as FoodDTO).ID;
                if (idBill == -1)
                {
                    BillDAO.Instance.InsertBill(table.ID);
                    BillInfoDAO.Instance.InsertBillInfo(BillDAO.Instance.GetMaxIdBill(), idFood, (int)nmFoodCount.Value);
                    LoadTable();
                }
                else
                {
                    BillInfoDAO.Instance.InsertBillInfo(idBill, idFood, (int)nmFoodCount.Value);
                }
            }
            ShowBill(table.ID);
        }
Exemple #3
0
        private void btnAddFood_Click(object sender, EventArgs e) // Sự kiện add Food
        {
            TableDTO table = lsvBill.Tag as TableDTO;             // lấy ra  table hiện tại đang chọn

            if (table == null)
            {
                MessageBox.Show(" Bạn Chưa chọn bàn !", "Thông Báo");
                return;
            }
            int idBill = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);                       // Lấy ra id Bill hiện tại bằng cách truyền idTable
            int foodID = (cbFood.SelectedItem as FoodDTO).ID;                                        // Lấy ra id Food từ combox
            int count  = (int)nmFoodCount.Value;                                                     //Số lượng fodd add vào lấy từ numberMenu

            if (idBill == -1)                                                                        // Khi chưa có bill
            {
                BillDAO.Instance.InsertBill(table.ID);                                               //tạo Bill mới
                BillInfoDAO.Instance.InsertBillInfo(BillDAO.Instance.GetMaxIDBill(), foodID, count); //Thêm Bill Info
                //Do thuật toán ID tự tăng lên id bill sẽ bằng GetMaxIDBill
            }
            else// Bill đã tồn tại
            {
                BillInfoDAO.Instance.InsertBillInfo(idBill, foodID, count);
            }
            ShowBill(table.ID);
            LoadTable();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TableDTO table = lsvBill.Tag as TableDTO;

            if (table == null)
            {
                MessageBox.Show("Hãy chọn bàn");
            }
            int idBill = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);
            int foodID = (cbFood.SelectedItem as FoodDTO).ID;
            int count  = (int)nmFoodCount.Value;

            if (idBill == -1)
            {
                BillDAO.Instance.InsertBill(table.ID);
                BillInfoDAO.Instance.InsertBillInfo(BillDAO.Instance.GetMaxIDBill(), foodID, count);
            }
            else
            {
                BillInfoDAO.Instance.InsertBillInfo(idBill, foodID, count);
            }

            ShowBill(table.ID);
            LoadTable();
        }
Exemple #5
0
        private void btnDeleteTable_Click(object sender, EventArgs e)
        {
            TableDTO selectedTable = lstViewBill.Tag as TableDTO;

            if (IsSelectTable(selectedTable))
            {
                try
                {
                    if (MessageBox.Show("Thao tác này có thể xóa cả hóa đơn đang lưu trên bàn\nHãy chắc rằng bạn muốn xóa", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.No)
                    {
                        List <BillDTO> billIDList = BillDAO.Instance.GetListBillID(selectedTable.MaBan);
                        foreach (BillDTO item in billIDList)
                        {
                            BillInfoDAO.Instance.DeleteBillInfo(item.MaHoaDon);
                            BillDAO.Instance.DeleteBill(item.MaHoaDon);
                        }
                        DeleteTable(selectedTable);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #6
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            TableDTO selectedTable = lstViewBill.Tag as TableDTO;

            if (IsSelectTable(selectedTable) == true)
            {
                int billID = BillDAO.Instance.GetBillID(selectedTable.MaBan);
                try
                {
                    if (billID != -1)
                    {
                        if (MessageBox.Show("Mức giảm giá: " + nudPromotion.Value.ToString() + "%\nBạn có chắc muốn thanh toán cho " + selectedTable.TenBan + " không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                        {
                            btnPay.Enabled = false;
                            txbCash.Text   = txbTotal.Text;
                            pnlPrint.Show();
                            CalculateSurplus();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 private void btnAddFood_Click(object sender, EventArgs e)
 {
     try
     {
         TableDTO table = lsvBill.Tag as TableDTO;
         if (table == null)
         {
             MessageBox.Show("Hãy chọn bàn!");
             return;
         }
         int idBill = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);
         try
         {
             int foodID = (cbFood.SelectedItem as FoodDTO).ID;
             int count  = (int)nmFoodCount.Value;
             if (idBill == -1)
             {
                 BillDAO.Instance.InsertBill(table.ID);
                 BillInfoDAO.Instance.InsertBillInfo(BillDAO.Instance.GetMaxIDBill(), foodID, count);
             }
             else
             {
                 BillInfoDAO.Instance.InsertBillInfo(idBill, foodID, count);
             }
         }
         catch
         {
             MessageBox.Show("Bạn chưa nhập món ăn cho danh mục này!");
         }
         ShowBill(table.ID);
         LoadTable();
     }
     catch { }
 }
Exemple #8
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                TableDTO      table         = lstBill.Tag as TableDTO;
                int           idBill        = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);
                frm_ThanhToan frm_ThanhToan = new frm_ThanhToan("HÓA ĐƠN THANH TOÁN", table.ID, idBill, txttotalPrice.Text);
                //this.Hide();
                frm_ThanhToan.ShowDialog();
                if (frm_ThanhToan._KetQua)
                {
                    ShowBill(table.ID);

                    LoadTable();
                    LoadTypeDrink();
                    btnThanhToan.Enabled   = false;
                    btnTamTinh.Enabled     = false;
                    cbLoaiThucUong.Enabled = false;
                    lstSanPham.Enabled     = false;
                    txttotalPrice.Text     = "0";
                }
            }
            catch
            {
                MessageBox.Show("Hệ thống đang bảo trì, vui lòng thử lại sau.");
            }
        }
Exemple #9
0
 private void DeleteTable(TableDTO selectedTable)
 {
     if (TableDAO.Instance.DeleteTable(selectedTable.MaBan))
     {
         ReLoad("1345");
     }
 }
        private void txttableid_TextChanged(object sender, EventArgs e)
        {
            if (dgvtable.SelectedCells.Count > 0)
            {
                int id = (int)dgvtable.SelectedCells[0].OwningRow.Cells["id"].Value;

                TableDTO table = DAO.TableDAO.GetTableById(id);

                cbstatustable.SelectedItem = table;

                int index = -1;
                int i     = 0;

                foreach (TableDTO item in cbstatustable.Items)
                {
                    if (item.ID == table.ID)
                    {
                        index = i;
                        break;
                    }
                    i++;
                }
                cbstatustable.SelectedIndex = index;
            }
        }
Exemple #11
0
        public List <TableDTO> listYeuCau(string cbo, string txt)
        {
            string query = "";

            if (cbo == "Mã bàn")
            {
                query = string.Format("select * from Ban where ID LIKE '%{0}%' ", txt);
            }
            else if (cbo == "Số ghế")
            {
                query = string.Format("select * from Ban where SoGhe = '{0}' ", txt);
            }
            else if (cbo == "Trạng thái")
            {
                query = string.Format("select * from Ban where TrangThai = '{0}' ", txt);
            }
            else
            {
                query = string.Format("select * from Ban where TinhTrang = '{0}' ", txt);
            }

            List <TableDTO> list = new List <TableDTO>();
            DataTable       data = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow row in data.Rows)
            {
                TableDTO item = new TableDTO(row);
                list.Add(item);
            }
            return(list);
        }
Exemple #12
0
 private void btnThanhToan_Click(object sender, EventArgs e)
 {
     try
     {
         TableDTO table      = lsvOrder.Tag as TableDTO;
         int      idBill     = BillDAO.Instance.GetUncheckBillByTableID(table.ID);
         double   totalPrice = Convert.ToDouble(txttotalPrice.Text);
         if (idBill != -1)
         {
             if (MessageBox.Show("Bạn có muốn thanh toán chứ ?", "Thanh toán", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
             {
                 BillDAO.Instance.CheckOutBill(idBill, (float)totalPrice);
                 ShowBill(table.ID);
                 BillDAO.Instance.UpdateBillAfterCheckOut(idBill);
                 lblNgayHienTai.Text = "";
                 txtTenBan.Text      = "";
                 txtTinhTrang.Text   = "";
                 LoadTable();
             }
         }
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Mời chọn bàn để thanh toán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #13
0
        private TableDTO CreateAddBillByIDTable(DrinkDTO drink)
        {
            TableDTO table = lstBill.Tag as TableDTO;


            int idBill = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);//lấy lên cái mã id của hóa đơn

            // int idDrink = (cbDrink. SelectedItem as DrinkDTO).ID;//thêm vào 1 gridview để hiển thị
            int idDrink  = drink.ID;
            int quantity = 1;

            //kiểm tra hóa đơn có chưa hay
            if (idBill == -1)//nếu chưa thì tạo 1 hóa đơn mới với mã hóa đơn
            {
                quantity = DetailBillBUS.GetQuantityDrink(idBill, idDrink);
                // sau khi tạo xong 1 hóa đơn mới thì thêm vào bảng chi tiết hóa đơn với các trường tương ứng
                DetailBillBUS.InsertDetailBill(BillBUS.GetIDBillMax(), idDrink, quantity + 1);
            }
            else//nếu đã có thì thêm nó vào cái cá bảng chi tiêt hóa đơn với các trường là mã hóa đơn, mã thức uống và số lượng
            {
                quantity = DetailBillBUS.GetQuantityDrink(idBill, idDrink);
                DetailBillBUS.InsertDetailBill(idBill, idDrink, quantity + 1);
            }
            return(table);
        }
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            try
            {
                TableDTO table           = lsvBill.Tag as TableDTO;
                int      idBill          = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);
                int      discount        = (int)nmDisCount.Value;
                float    totalPrice      = float.Parse(txbTotalPrice.Text.Split(',')[0]);
                float    finalTotalPrice = totalPrice - (totalPrice / 100) * discount;

                if (idBill != -1)
                {
                    if (MessageBox.Show(string.Format("Bạn có chắc thanh toán hóa đơn cho {0} \nGiảm giá = {1}% ", table.Name, discount), "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                    {
                        BillDAO.Instance.CheckOut(idBill, discount, finalTotalPrice * 1000);
                        //print here
                        PrintDialog printDialog = new PrintDialog();
                        if (printDialog.ShowDialog() == DialogResult.OK)
                        {
                            printDoc.Print();
                        }
                        //end print
                        ShowBill(table.ID);
                        LoadTable();
                    }
                }
            }
            catch { }
        }
Exemple #15
0
 private void btnHuyDon_Click(object sender, EventArgs e)
 {
     try
     {
         TableDTO table  = lsvOrder.Tag as TableDTO;
         int      idBill = BillDAO.Instance.GetUncheckBillByTableID(table.ID);
         if (idBill != -1)
         {
             if (MessageBox.Show("Bạn có muốn xóa chứ ?", "Xóa bàn", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == System.Windows.Forms.DialogResult.Yes)
             {
                 BillDAO.Instance.huyBan(idBill, table.ID);
                 ShowBill(table.ID);
                 string b = BillDAO.Instance.getDayBillByTableID(table.ID);
                 lblNgayHienTai.Text = b;
                 lblNgayHienTai.Text = "";
                 txtTenBan.Text      = "";
                 txtTinhTrang.Text   = "";
                 LoadTable();
             }
         }
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Bàn chưa có hóa đơn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #16
0
        private void btncheckout_Click(object sender, EventArgs e)
        {
            if (lsvBill.Tag == null)
            {
                MessageBox.Show("Hãy chọn bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            TableDTO table   = lsvBill.Tag as TableDTO;
            int      idtable = table.ID;
            int      idbill  = BillDAO.GetUncheckedBillIDByTableID(idtable);
            int      giamgia = (int)nmGiamGia.Value;
            //double TongTien = Convert.ToDouble(txtTongTien.Text.Split(',')[0]);
            //double TongTienGiamGia = TongTien - (TongTien/100)*giamgia;
            float TongTienGiamGia = thanhtoan - (thanhtoan / 100) * giamgia;

            if (idbill != -1)
            {
                if (MessageBox.Show(string.Format("Bạn có chắc thanh toán hóa đơn với số tiền là {0}-({1}/100)*{2} = {3}", thanhtoan, thanhtoan, giamgia, TongTienGiamGia), "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    BillDAO.CheckOut(idbill, giamgia, TongTienGiamGia);
                    Showbill(idtable);
                    LoadTable();
                }
            }
            nmGiamGia.Value = 0;
        }
Exemple #17
0
        private void btnaddfood_Click(object sender, EventArgs e)
        {
            if (lsvBill.Tag == null)
            {
                MessageBox.Show("Hãy chọn bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            lsvBill.Items.Clear();
            TableDTO table = lsvBill.Tag as TableDTO;                   //mục đích: lấy id của bàn đang được chọn để thêm

            int idbill = BillDAO.GetUncheckedBillIDByTableID(table.ID); //từ id bàn => lấy được id của hóa đơn
            int idfood = (cbThucAn.SelectedItem as FoodDTO).Id;
            int count  = (int)nmfoodcount.Value;

            if (idbill == -1)//case: chưa có hóa đơn, bàn còn trống
            {
                BillDAO.InsertBill(table.ID);
                //tham số idhoadon: hoa don them sau cung => co id la lon nhat
                //tham số id thức ăn: lấy từ combobox
                //tham số số lượng thức ăn lấy từ nmfoodcount
                BillInfoDAO.InsertBillInfo(BillDAO.GetMaxIdBill(), idfood, count);
            }
            else//case: hóa đơn đã tồn tại => sẽ thêm món mới hoặc cập nhật thêm số lượng món
                //kiểm tra món đã tồn tại hay chưa ta xử lí bên dưới server
            {
                BillInfoDAO.InsertBillInfo(idbill, idfood, count);
            }

            nmfoodcount.Value = 1;
            Showbill(table.ID);
            LoadTable();
        }
Exemple #18
0
 private void btnCreateTable_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.txtTableName.Text == "")
         {
             MessageBox.Show("Bạn không thể thêm nếu như để trống một trường dữ liệu nào.", "Thông báo", MessageBoxButtons.OK);
         }
         else
         {
             TableDTO sp = new TableDTO();
             sp.NameTable = txtTableName.Text;
             sp.Status    = 0;
             if (TableBUS.InsertTable(sp))
             {
                 ShowTable();
                 DeleteTextTable();
                 MessageBox.Show("Bạn đã thêm mới thành công", "Thông báo", MessageBoxButtons.OK);
             }
             else
             {
                 MessageBox.Show("Bạn thêm mới thất bại, thử lại.", "Thông báo", MessageBoxButtons.OK);
             }
         }
     }
     catch
     {
         MessageBox.Show("Hệ thống đang bảo trì chức năng này, vui lòng quay lại sau nhé!", "Thông báo", MessageBoxButtons.OK);
     }
 }
Exemple #19
0
        public TableDTO DeleteTable(TableDTO tableDTO)
        {
            var Table = _repository.GetTables().WithTableId(tableDTO.TableId);

            _repository.RemoveTable(Table);

            return(tableDTO);
        }
Exemple #20
0
 protected bool ValidateTable(TableDTO tableDTO)
 {
     if (tableDTO.Seating == 0)
     {
         return(false);
     }
     return(true);
 }
Exemple #21
0
 public static DbTable RestoreSerializableDTO(DbTable current, TableDTO model)
 {
     var clonedTable = new DbTable(current.Metadata)
     {
         TableName = current.TableName,
         MainDict = model.Rows.ToDictionary(x => x.Key, x => DbRow.RestoreSerializableDTO(current, x.Value))
     };
     return clonedTable;
 }
Exemple #22
0
 private void lstSanPham_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstSanPham.SelectedItems.Count > 0)
     {
         DrinkDTO drink = lstSanPham.SelectedItems[0].Tag as DrinkDTO;
         // Them qua ListView
         //kiểm tra đã chọn bàn hay chưa
         try
         {
             if (choseTable != null)
             {
                 if ((objTable as Button).Tag != null)
                 {
                     Button btnTable = (objTable as Button);
                     //tag cái bàn đang chọn vào
                     TableDTO table   = (objTable as Button).Tag as TableDTO;
                     int      idTable = table.ID;
                     if (TableBUS.GetStatusByIDTable(idTable) == 0)
                     {
                         DialogResult kq = MessageBox.Show("Bạn đang chọn bàn mới.\n Bạn có muốn tạo hóa đơn mới cho bàn này chứ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                         if (kq == DialogResult.OK)
                         {
                             btnThanhToan.Enabled = true;
                             btnTamTinh.Enabled   = true;
                             lstBill.Tag          = (choseTable as Button).Tag;
                             //ShowBill(idTable);
                             // Cap nhat trang thai bàn
                             TableBUS.UpdateStatusTable(1, idTable);
                             // Tao hóa đơn mới ở đây.
                             BillBUS.InsertBill(DateTime.Now, 0, Program.sAccount.ID, idTable);
                             txtHD.Text    = "HD00" + (string)BillBUS.GetIDBillNoPaymentByIDTable((int)idTable).ToString();
                             btnTable.Text = table.NameTable + Environment.NewLine + "Có";
                         }
                         else
                         {
                             lstBill.Items.Clear();
                             btnThanhToan.Enabled   = false;
                             btnTamTinh.Enabled     = false;
                             cbLoaiThucUong.Enabled = false;
                             txtHD.Text             = "";
                         }
                     }
                     table = CreateAddBillByIDTable(drink);
                     ShowBill(table.ID);
                 }
             }
             else
             {
                 MessageBox.Show("Bạn chưa chọn bàn để thêm thức uống. Vui lòng chọn bàn để tiếp tục!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
             }
         }
         catch
         {
             MessageBox.Show("Hệ thống đang bảo trì, bạn quay lại sau nhé!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
         }
     }
 }
 public void Create(TableDTO item)
 {
     if (item.PeopleAmount < 0)
     {
         throw new NegativeNumberException("Pople amount must be more then 0. ");
     }
     _data.Tables.Create(Mapper.Map <Table>(item));
     _data.Save();
 }
Exemple #24
0
        private void nudPromotion_ValueChanged(object sender, EventArgs e)
        {
            TableDTO selectedTable = lstViewBill.Tag as TableDTO;

            if (selectedTable != null)
            {
                ShowBill(selectedTable.MaBan);
            }
        }
Exemple #25
0
 public TableDTO ToSerializableDTO()
 {
     var jsonObj = new TableDTO
     {
         Name = this.TableName,
         Rows = this.MainDict.ToDictionary(x => x.Key, x => x.Value.ToSerializableDTO())
     };
     return jsonObj;
 }
Exemple #26
0
 private bool IsSelectTable(TableDTO selectedTable)
 {
     if (selectedTable == null)
     {
         MessageBox.Show("Vui lòng chọn bàn.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     return(true);
 }
Exemple #27
0
        public static bool DeleteTable(TableDTO tb)
        {
            string query = "Exec USP_DeleteTable @idtable";

            if (DataProvider.Instance.ExcuteNonQuery(query, new object[] { tb.ID }) == 1)
            {
                return(true);
            }
            return(false);
        }
Exemple #28
0
        public TableDTO EditTable(TableDTO tableDTO)
        {
            var Table = _repository.GetTables().WithTableId(tableDTO.TableId);

            Table.TableId   = tableDTO.TableId;
            Table.BookingId = tableDTO.BookingId;
            _repository.PostTable(Table);

            return(tableDTO);
        }
Exemple #29
0
        public static bool InsertTable(TableDTO tb)
        {
            string query = "Exec USP_InsertTable @nametable , @status ";

            if (DataProvider.Instance.ExcuteNonQuery(query, new object[] { tb.NameTable, tb.Status }) == 1)
            {
                return(true);
            }
            return(false);
        }
        private TableDTO ToTableDTO(DataAccess.Table item)
        {
            TableDTO result = new TableDTO();

            result.Name = item.Name;
            result.ID   = item.ID;
            //result.Alias = item.Alias;
            //result.IsInheritanceImplementation = item.IsInheritanceImplementation==true;
            return(result);
        }