private void LoadDSCTHD(int iDHoaDon)
        {
            try
            {
                using (var k = new AppCode.QuanCafe())
                {
                    var kq = k.TimDSCTHD(iDHoaDon);
                    grvCTBanTest.DataSource = kq;

                    //var result = from p in k.DSCTHD
                    //             from c in k.DSDoUong
                    //             where p.IDDoUong == c.IDDoUong
                    //             select new
                    //             {
                    //                 TenDoUong =  c.TenDoUong,
                    //             };
                    //MessageBox.Show("Ket qua=" + result.Count().ToString());
                    //   grvTest.DataSource = kq;
                    //Tủy chỉnh dataGridView control
                    LoadTongTien();
                }
            }


            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;
            }
        }
        public static List <CTHoaDon> DSCTHD()
        {
            var ds = new List <CTHoaDon>();

            using (var k = new AppCode.QuanCafe())
            {
                ds = k.TimDSCTHD(AppCode.STHoaDon.idHoaDon);

                return(ds);
            }
        }
        private void txtGiamGia_TextChanged(object sender, EventArgs e)
        {
            double t       = 0;
            double giamgia = 0;

            try
            {
                if (double.TryParse(txtGiamGia.Text, out giamgia))
                {
                    if (giamgia >= 0 && giamgia <= 100)
                    {
                        TinhTien.giamgia = giamgia;

                        try
                        {
                            using (var k = new AppCode.QuanCafe())
                            {
                                foreach (var item in k.TimDSCTHD(AppCode.STHoaDon.idHoaDon))
                                {
                                    t += ((item.SoLuong * item.GiaBan) -
                                          (item.SoLuong * item.GiaBan) *
                                          (double.Parse(txtGiamGia.Text) / 100));
                                }
                            }
                        }
                        catch
                        {
                        }

                        txtTongTien.Text = t.ToString();
                    }
                    else
                    {
                        giamgia         = 0;
                        txtGiamGia.Text = "0";
                        MessageBox.Show("Giam giá không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                else
                {
                    giamgia         = 0;
                    txtGiamGia.Text = "0";
                    MessageBox.Show("Giam giá không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            catch
            {
                giamgia         = 0;
                txtGiamGia.Text = "0";
                return;
            }
        }
        private void LoadTongTien()
        {
            double t = 0;

            try
            {
                using (var k = new AppCode.QuanCafe())
                {
                    foreach (var item in k.TimDSCTHD(AppCode.STHoaDon.idHoaDon))
                    {
                        t += ((item.SoLuong * item.GiaBan));
                    }
                }
            }
            catch
            {
            }
            txtTamTinh.Text  = t.ToString();
            txtTongTien.Text = txtTamTinh.Text;
        }
        private void grvCTBanTest_SelectionChanged(object sender, EventArgs e)
        {
            int rowSelected = grvCTBanTest.CurrentRow.Index;

            try
            {
                using (var k = new AppCode.QuanCafe())
                {
                    var kq = k.TimDoUong(k.TimDSCTHD(AppCode.STHoaDon.idHoaDon)[rowSelected].IDDoUong);
                    AppCode.STDoUong.id      = kq.IDDoUong;
                    AppCode.STDoUong.soLuong = int.Parse(grvCTBanTest.Rows[rowSelected].Cells[2].Value.ToString());
                    AppCode.STDoUong.giaban  = int.Parse(grvCTBanTest.Rows[rowSelected].Cells[3].Value.ToString());
                    AppCode.STDoUong.giagoc  = kq.GiaGoc;
                    AppCode.STDoUong.loai    = kq.IDLoai;
                    AppCode.STDoUong.ten     = kq.TenDoUong;
                }
            }
            catch
            {
                return;
            }
        }