internal string ThemKhuyenMai(KhuyenMai loai)
 {
     loai.MaKM  = TaoMa();
     loai.AnhCT = loai.MaKM + "1.jpg";
     db.KhuyenMais.Add(loai);
     db.SaveChanges();
     return(loai.MaKM);
 }
        internal void EditKhuyenMai(KhuyenMai loai)
        {
            KhuyenMai lsp = db.KhuyenMais.Find(loai.MaKM);

            lsp.TenCT           = loai.TenCT;
            lsp.NgayBatDau      = loai.NgayBatDau;
            lsp.NgayKetThuc     = loai.NgayKetThuc;
            lsp.NoiDung         = loai.NoiDung;
            db.Entry(lsp).State = EntityState.Modified;
            db.SaveChanges();
        }
        internal void DeleteKhuyenMai(string id)
        {
            var lst = db.SanPhamKhuyenMais.Where(m => m.MaKM.Equals(id)).ToList();

            foreach (var item in lst)
            {
                DeleteSPKhuyenMai(item.MaKM, item.MaSP);
            }
            KhuyenMai loai = db.KhuyenMais.Find(id);

            db.KhuyenMais.Remove(loai);
            db.SaveChanges();
        }