コード例 #1
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblUserGroup o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblUserGroups.Where(x => x.Id == o.Id).SingleOrDefault();
             res.Username = o.Username;
             res.GroupId  = o.GroupId;
             res.Status   = o.Status;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblUserGroup::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblUserGroup::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #2
0
ファイル: TblUserDao.cs プロジェクト: manhtuan165/ISD
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblUser obj)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblUsers.Where(s => s.Username == obj.Username).Single();
             res.Password    = obj.Password;
             res.Name        = obj.Name;
             res.Email       = obj.Email;
             res.Phone       = obj.Phone;
             res.Mobile      = obj.Mobile;
             res.Status      = obj.Status;
             res.Description = obj.Description;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblUserDao::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblUserDao::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #3
0
ファイル: TblUnitDao.cs プロジェクト: manhtuan165/ISD
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: tạo đối tượng mới
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>
 public void Create(TblUnit o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             if (o != null)
             {
                 db.TblUnits.Add(o);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblUnitDao::Create" + ex.Message);
         }
         else
         {
             throw new Exception("TblUnitDao::Create" + ex.Message);
         }
     }
 }
コード例 #4
0
ファイル: TblUnitDao.cs プロジェクト: manhtuan165/ISD
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public void Update(TblUnit o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblUnits.Where(x => x.UnitId == o.UnitId).Single();
             res.Name    = o.Name;
             res.Phone   = o.Phone;
             res.Fax     = o.Fax;
             res.Email   = o.Email;
             res.Status  = o.Status;
             res.Address = o.Address;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblUnitDao::Update" + ex.Message);
         }
         else
         {
             throw new Exception("TblUnitDao::Update" + ex.Message);
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblGroup o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblGroups.Where(x => x.GroupId == o.GroupId).Single();
             res.Name        = o.Name;
             res.Status      = o.Status;
             res.Description = o.Description;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblGroupDao::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblGroupDao::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #6
0
ファイル: TblGroupNewsDao.cs プロジェクト: manhtuan165/ISD
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblGroupNew o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblGroupNews.Where(w => w.GroupNewsId == o.GroupNewsId).SingleOrDefault();
             res.Name       = o.Name;
             res.Status     = o.Status;
             res.Ord        = o.Ord;
             res.ParentId   = o.ParentId;
             res.Path       = o.Path;
             res.IsMenu     = o.IsMenu;
             res.IsHome     = o.IsHome;
             res.UrlPath    = o.UrlPath;
             res.UrlPathEng = o.UrlPathEng;
             res.NameEng    = o.NameEng;
             res.PathEng    = o.PathEng;
             res.Controller = o.Controller;
             res.Action     = o.Action;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblGroupNewsDao::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblGroupNewsDao::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #7
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblNewsDraff obj)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblNewsDraffs.Where(s => s.NewsId == obj.NewsId).SingleOrDefault();
             res.GroupNewsId  = obj.GroupNewsId;
             res.Title        = obj.Title;
             res.ShortContent = obj.ShortContent;
             res.Content      = obj.Content;
             res.BigImage     = obj.BigImage;
             res.SmaallImage  = obj.SmaallImage;
             res.IsHome       = obj.IsHome;
             res.IsEvent      = obj.IsEvent;
             res.IsWeek       = obj.IsWeek;
             res.Metatitle    = obj.Metatitle;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblNewsDraffDao::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblNewsDraffDao::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #8
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblChart o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblCharts.Where(x => x.id == 1).SingleOrDefault();
             res.src1   = o.src1;
             res.src2   = o.src2;
             res.src3   = o.src3;
             res.src4   = o.src4;
             res.src5   = o.src5;
             res.Status = o.Status;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblChartDao::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblChartDao::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #9
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: tạo đối tượng mới
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>
 public void Create(TblFileNewsDraff o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             db.TblFileNewsDraffs.Add(o);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblFileNewsDraff::Create::" + ex.Message);
         }
         else
         {
             throw new Exception("TblFileNewsDraff::Create::" + ex.InnerException.Message);
         }
     }
 }
コード例 #10
0
ファイル: TblRoleDao.cs プロジェクト: manhtuan165/ISD
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: xóa đối tượng
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public void Delete(TblRole o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             db.TblRoles.Add(o);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblRoleDao::Delete::" + ex.Message);
         }
         else
         {
             throw new Exception("TblRoleDao::Delete::" + ex.InnerException.Message);
         }
     }
 }
コード例 #11
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: xóa đối tượng
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public void Delete(TblUserGroup o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblUserGroups.Where(x => x.Id == o.Id).SingleOrDefault();
             db.TblUserGroups.Remove(res);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblUserGroup::Delete::" + ex.Message);
         }
         else
         {
             throw new Exception("TblUserGroup::Delete::" + ex.InnerException.Message);
         }
     }
 }
コード例 #12
0
ファイル: TblLogDao.cs プロジェクト: manhtuan165/ISD
 public void Create(TblLog o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblLogs.Where(x => x.LogId == o.LogId).SingleOrDefault();
             db.TblLogs.Add(res);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblLogDao::FindByAll::" + ex.Message);
         }
         else
         {
             throw new Exception("TblLogDao::FindByAll::" + ex.InnerException.Message);
         }
     }
 }
コード例 #13
0
 public void Update(TblGallery o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblGalleries.Where(x => x.Id == o.Id).SingleOrDefault();
             res.Name     = o.Name;
             res.ImageUrl = o.ImageUrl;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblGallery::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblGallery::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #14
0
 public void Update(TblComment o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblComments.Where(x => x.Id == o.Id).SingleOrDefault();
             res.Name    = o.Name;
             res.Content = o.Content;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblCommentDao::Delete::" + ex.Message);
         }
         else
         {
             throw new Exception("TblCommentDao::Delete::" + ex.InnerException.Message);
         }
     }
 }
コード例 #15
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>
 public void Update(TblFileNewsDraff obj)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblFileNewsDraffs.Where(x => x.Id == obj.Id).SingleOrDefault();
             res.NewsId = obj.NewsId;
             res.FileId = obj.FileId;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblFileNewsDraff::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblFileNewsDraff::Update::" + ex.InnerException.Message);
         }
     }
 }
コード例 #16
0
ファイル: TblGroupRoleDao.cs プロジェクト: manhtuan165/ISD
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: cập nhật đối tượng
 /// </summary>
 /// <param name=""></param>
 /// <returns></returns>\
 public void Update(TblGroupRole o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblGroupRoles.Where(x => x.Id == o.Id).SingleOrDefault();
             res.GroupId = o.GroupId;
             res.RoleId  = o.RoleId;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblGroupRoleDao::Update::" + ex.Message);
         }
         else
         {
             throw new Exception("TblGroupRoleDao::Update::" + ex.InnerException.Message);
         }
     }
 }