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
     }
 }
Example #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);
            }
        }
 partial void DeleteHocPhan(HocPhan instance);
 partial void UpdateHocPhan(HocPhan instance);
 partial void InsertHocPhan(HocPhan instance);
Example #8
0
 public void Update(HocPhan hp)
 {
     dal.Update(hp);
 }
Example #9
0
 public List<HocPhan> Search(HocPhan hp)
 {
     return dal.Search(hp);
 }
Example #10
0
 public void Insert(HocPhan hp)
 {
     dal.Insert(hp);
 }
Example #11
0
 public void Delete(HocPhan hp)
 {
     dal.Delete(hp);
 }
Example #12
0
 public List<HocPhan> Search(HocPhan hp)
 {
     return db.HocPhans.Where(tp => tp.MaHP.Equals(hp.MaHP)).ToList();
 }
Example #13
0
 public void Insert(HocPhan hp)
 {
     db.HocPhans.InsertOnSubmit(hp);
     db.SubmitChanges();
 }
Example #14
0
 public void Delete(HocPhan hp)
 {
     temp = db.HocPhans.Where(tp=>tp.MaHP.Equals(hp.MaHP)).First();
     db.HocPhans.DeleteOnSubmit(temp);
     db.SubmitChanges();
 }