public int DelHocPhan(string id)
 {
     try
     {
         HocPhan x = db.HocPhans.Where(s => s.ID_HocPhan.Trim() == id.Trim()).FirstOrDefault();
         if (x == null)
         {
             return(1); // không tìm thấy học phần
         }
         else
         {
             if (db.LopHocPhans.Where(s => s.ID_HocPhan.Trim() == id.Trim()).Count() > 0)
             {
                 return(2); //có lớp học phần ko thể xóa
             }
             else
             {
                 db.HocPhans.Remove(x);
                 db.SaveChanges();
                 return(0); //Xóa thành công;
             }
         }
     }
     catch (Exception)
     {
         return(3);//lỗi
     }
 }
Пример #2
0
 public void Update(HocPhan hp)
 {
     temp = db.HocPhans.Where(tp => tp.MaHP.Equals(hp.MaHP)).First();
     temp.TenHP = hp.TenHP;
     temp.SoTietLT = hp.SoTietLT;
     temp.SoTietTH = hp.SoTietTH;
     db.SubmitChanges();
 }
 public eHocPhan AddNewHocPhan(eHocPhan hp)
 {
     try
     {
         HocPhan x = new HocPhan();
         x.ID_HocPhan = hp.ID_HocPhan;
         x.TenMonHoc  = hp.TenMonHoc;
         x.SoTC       = hp.SoTC;
         db.HocPhans.Add(x);
         db.SaveChanges();
         return(hp);
     }
     catch
     {
         return(null);
     }
 }
        public eHocPhan EditHocPhan(string id, eHocPhan hp)
        {
            try
            {
                HocPhan x = db.HocPhans.Where(m => m.ID_HocPhan == id).FirstOrDefault();
                if (x == null)
                {
                    return(null);
                }
                else
                {
                    x.TenMonHoc = hp.TenMonHoc;
                    x.SoTC      = hp.SoTC;
                    db.SaveChanges();

                    return(hp);
                }
            }
            catch
            {
                return(null);
            }
        }
Пример #5
0
 partial void DeleteHocPhan(HocPhan instance);
Пример #6
0
 partial void UpdateHocPhan(HocPhan instance);
Пример #7
0
 partial void InsertHocPhan(HocPhan instance);
Пример #8
0
 public void Update(HocPhan hp)
 {
     dal.Update(hp);
 }
Пример #9
0
 public List<HocPhan> Search(HocPhan hp)
 {
     return dal.Search(hp);
 }
Пример #10
0
 public void Insert(HocPhan hp)
 {
     dal.Insert(hp);
 }
Пример #11
0
 public void Delete(HocPhan hp)
 {
     dal.Delete(hp);
 }
Пример #12
0
 public List<HocPhan> Search(HocPhan hp)
 {
     return db.HocPhans.Where(tp => tp.MaHP.Equals(hp.MaHP)).ToList();
 }
Пример #13
0
 public void Insert(HocPhan hp)
 {
     db.HocPhans.InsertOnSubmit(hp);
     db.SubmitChanges();
 }
Пример #14
0
 public void Delete(HocPhan hp)
 {
     temp = db.HocPhans.Where(tp=>tp.MaHP.Equals(hp.MaHP)).First();
     db.HocPhans.DeleteOnSubmit(temp);
     db.SubmitChanges();
 }