示例#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(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);
         }
     }
 }
示例#2
0
 public ActionResult TblChartUpdate(string src1, string src2, string src3, string src4, string src5)
 {
     try
     {
         TblChart o = new TblChart();
         o.src1 = src1;
         o.src2 = src2;
         o.src3 = src3;
         o.src4 = src4;
         o.src5 = src5;
         new TblChartDao().Update(o);
         SetAlert("cập nhật thành công", "success");
         return(RedirectToAction("TblChartUpdate"));
     }
     catch (Exception ex)
     {
         logger.Info(ControllerName + "::TblChartUpdate::" + ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
示例#3
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: tìm kiếm đối tượng theo khóa chính
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public TblChart FindById(TblChart o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             return(db.TblCharts.SingleOrDefault(x => x.id == o.id));
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblChartDao::FindById::" + ex.Message);
         }
         else
         {
             throw new Exception("TblChartDao::FindById::" + ex.InnerException.Message);
         }
     }
 }
示例#4
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(TblChart o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             db.TblCharts.Add(o);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblChartDao::Create::" + ex.Message);
         }
         else
         {
             throw new Exception("TblChartDao::Create::" + ex.InnerException.Message);
         }
     }
 }
示例#5
0
 /// <summary>
 /// Author: Phạm Huy Hùng
 /// Todo: xóa đối tượng
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public void Delete(TblChart o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblCharts.Where(x => x.id == o.id).Single();
             db.TblCharts.Remove(res);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblChartDao::Delete::" + ex.Message);
         }
         else
         {
             throw new Exception("TblChartDao::Delete::" + ex.InnerException.Message);
         }
     }
 }