Ejemplo n.º 1
0
 public ActionResult Create(Go_Out go_Out)
 {
     if (ModelState.IsValid)
     {
         var dao = new GoOutDAO();
         go_Out.CreatedDate = DateTime.Now;
         var user = (UserLogin)Session[CommonConstants.USER_SESSION];
         go_Out.CreatedBy = user.EmpCode + "|" + user.FullName;
         int id = dao.Insert(go_Out, user.EmpCode);
         if (id > 0)
         {
             return(RedirectToAction("History", "GoOut"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm mới thất bại");
         }
     }
     else
     {
         ModelState.AddModelError("", "Thêm mới thất bại");
         return(View("Create"));
     }
     return(RedirectToAction("History"));
 }
Ejemplo n.º 2
0
 public ActionResult Edit(Go_Out go_Out)
 {
     if (ModelState.IsValid)
     {
         var dao  = new GoOutDAO();
         var user = (UserLogin)Session[CommonConstants.USER_SESSION];
         go_Out.ModifiedBy = user.EmpCode + "|" + user.FullName;
         var res = dao.Update(go_Out, user.EmpCode);
         if (res /*&& (go_Out.EstimatedDateReturn >= go_Out.EstimatedDateOut)*/)
         {
             return(RedirectToAction("History", "GoOut"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật thất bại");
         }
     }
     return(View("History"));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Hàm update dành cho PIC
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Update(Go_Out entity, string modifiedBy)
 {
     try
     {
         var goOut = dbContext.Go_Out.Find(entity.ID);
         goOut.EmpCode             = entity.EmpCode;
         goOut.Shift               = entity.Shift;
         goOut.Reason              = entity.Reason;
         goOut.EstimatedDateOut    = entity.EstimatedDateOut;
         goOut.EstimatedTimeOut    = entity.EstimatedTimeOut;
         goOut.EstimatedDateReturn = entity.EstimatedDateReturn;
         goOut.EstimatedTimeReturn = entity.EstimatedTimeReturn;
         goOut.ModifiedBy          = entity.ModifiedBy;
         goOut.ModifiedDate        = DateTime.Now;
         dbContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Phương thức thêm
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Insert(Go_Out entity, string createdBy)
 {
     dbContext.Go_Out.Add(entity);
     dbContext.SaveChanges();
     return(entity.ID);
 }