public int InsertChiTietHoaDon(eChiTietChuongTrinhKhuyenMai Ctiet)
        {
            var Sanpham = from i in db.SanPhams
                          where i.MaSP == Ctiet.MaSP
                          select i;

            if (Sanpham.Any())
            {
                var Chitiet = from i in db.ChiTietKhuyenMais
                              where i.MaCT == Ctiet.MaCT && i.MaSp == Ctiet.MaSP
                              select i;
                if (Chitiet.Any())
                {
                    throw new Exception("There Already Have");
                }
                else
                {
                    ChiTietKhuyenMai Ct = new ChiTietKhuyenMai();
                    Ct.MaCT         = Ctiet.MaCT;
                    Ct.MaSp         = Ctiet.MaSP;
                    Ct.DonGia       = Convert.ToDecimal(Ctiet.DonGia);
                    Ct.MucGiam      = Ctiet.MucGiam;
                    Ct.GiaKhuyenMai = Convert.ToDecimal(Ctiet.GiaKhuyenMai);
                    db.ChiTietKhuyenMais.InsertOnSubmit(Ct);
                    db.SubmitChanges();
                    return(1);
                }
            }
            else
            {
                throw new Exception("Invaild SanPham");
            }
        }
        public List <eChiTietChuongTrinhKhuyenMai> GetALLChitietKhuyenMaiByMaCT(string Ma)
        {
            var Chitiet = from i in db.ChiTietKhuyenMais
                          where i.MaCT == Ma
                          select i;
            List <eChiTietChuongTrinhKhuyenMai> Ls = new List <eChiTietChuongTrinhKhuyenMai>();

            foreach (ChiTietKhuyenMai Ct in Chitiet.ToList())
            {
                eChiTietChuongTrinhKhuyenMai newCt = new eChiTietChuongTrinhKhuyenMai();
                newCt.MaCT         = Ct.MaCT;
                newCt.MaSP         = Ct.MaSp;
                newCt.MucGiam      = Convert.ToDouble(Ct.MucGiam);
                newCt.DonGia       = Convert.ToDouble(Ct.DonGia);
                newCt.GiaKhuyenMai = Convert.ToDouble(Ct.GiaKhuyenMai);
                Ls.Add(newCt);
            }
            return(Ls);
        }