private void btnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                using (var k = new AppCode.QuanCafe())
                {
                    var timhd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon);

                    timhd.TrangThai = true;
                    timhd.GiamGia   = TinhTien.giamgia;
                    //MessageBox.Show(timhd.GiamGia.ToString());
                    k.SuaHD(timhd);
                    var timban = k.TimBan(AppCode.STBan.idBan);
                    //cap nhat
                    timban.TrangThai = "Trống";
                    k.CapNhatBan(timban);
                    txtGiamGia.Text  = string.Empty;
                    txtTamTinh.Text  = string.Empty;
                    txtTongTien.Text = string.Empty;

                    flpDSBan.Controls.Clear();
                    LoadDSBan();
                    grvCTBanTest.DataSource = null;

                    fThanhToan f = new fThanhToan();
                    f.ShowDialog();
                }
            }
            catch
            {
            }
        }
        private void LoadCTHD()
        {
            try
            {
                using (var k = new AppCode.QuanCafe())
                {
                    List <CTHoaDon> dscthd = new List <CTHoaDon>();

                    var tthd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon);
                    dscthd = k.TimDSCTHD(tthd.IDHoaDon);
                    //Set data
                    lblSoban.Text       = k.TimBan(tthd.IDBan).TenBan;
                    lblNhanVienLap.Text = k.TimNV(tthd.IDNhanVienLap).TenNV;
                    lblNgayLap.Text     = DateTime.Now.ToString("dd/MM/yyyy");
                    grvCTHD.DataSource  = dscthd;
                    lblGiamGia.Text     = TinhTien.giamgia.ToString() + "%";

                    //Tong tien
                    double t = 0;
                    foreach (var item in dscthd)
                    {
                        t += ((item.SoLuong * item.GiaBan));
                    }
                    lblTongTien.Text = (t - (t * TinhTien.giamgia / 100)).ToString() + " VNĐ";
                }
            }
            catch
            {
                return;
            }
        }
        //Phim tat
        private void fManager_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.F)
            {
                TimKiem();
            }
            if (e.Control && e.KeyCode == Keys.E)
            {
                this.Close();
            }
            if (e.Control && e.KeyCode == Keys.R)
            {
                hóaĐơnToolStripMenuItem_Click(sender, e);
            }
            if (e.Control && e.KeyCode == Keys.T)
            {
                try
                {
                    using (var k = new AppCode.QuanCafe())
                    {
                        var timhd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon);

                        timhd.TrangThai = true;
                        timhd.GiamGia   = TinhTien.giamgia;
                        //MessageBox.Show(timhd.GiamGia.ToString());
                        k.SuaHD(timhd);
                        var timban = k.TimBan(AppCode.STBan.idBan);

                        timban.TrangThai = "Trống";
                        k.CapNhatBan(timban);
                        flpDSBan.Controls.Clear();
                        LoadDSBan();
                        grvCTBanTest.DataSource = null;

                        fThanhToan f = new fThanhToan();
                        f.ShowDialog();
                    }
                }
                catch
                {
                }
            }
        }
        private void btnHuyBan_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn muốn hủy bàn này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) != System.Windows.Forms.DialogResult.Cancel)
            {
                var kqtimban = XuLyDuLieu.DocDuLieu("EXEC SP_TimBan '" + AppCode.STBan.idBan + "' ");
                var tenban   = kqtimban.Rows[0]["TenBan"].ToString();
                int idban    = AppCode.STBan.idBan;
                XuLyDuLieu.ThucThiThemXoaSua("SP_UPDATE_BAN '" + idban + "','" + tenban + "',Trống");

                try
                {
                    using (var k = new AppCode.QuanCafe())
                    {
                        var timhd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon);

                        timhd.TrangThai = true;
                        timhd.GiamGia   = TinhTien.giamgia;
                        //MessageBox.Show(timhd.GiamGia.ToString());
                        k.SuaHD(timhd);
                        var timban = k.TimBan(AppCode.STBan.idBan);
                        //cap nhat
                        timban.TrangThai = "Trống";
                        k.CapNhatBan(timban);
                        txtGiamGia.Text  = "0";
                        txtTamTinh.Text  = "0";
                        txtTongTien.Text = "0";

                        lblTenBan.Text          = "";
                        grvCTBanTest.DataSource = null;
                    }
                }
                catch
                {
                }


                flpDSBan.Controls.Clear();
                LoadDSBan();
            }
        }