Exemple #1
0
        public HistoryCheckInModel GetHistoryCheckInByHistoryId(int HistoryId, string UserName, out ErrorModel errorModel)
        {
            HistoryCheckInModel ret = null;

            errorModel = new ErrorModel();
            try
            {
                DBHelper db = new DBHelper(GlobalInfo.PKG_TMS_CHECKINOUT + ".sp_get_HistoryCheckin_By_HistoryId", UserName)
                              .addParamOutput("oResult")
                              .addParam("pUserRequest", UserName)
                              .addParam("pJson", JsonHelper.Serialize(new { HistoryId = HistoryId, UserName = UserName }))
                              .ExecuteStore();

                ret = db.getFirst <HistoryCheckInModel>();

                errorModel.ErrorCode = ret != null ? 1 : 0;
                errorModel.ErrorMsg  = errorModel.ErrorCode == 1 ? "Success" : "fail";
            }
            catch (Exception ex)
            {
                errorModel.ErrorCode   = -1;
                errorModel.ErrorMsg    = ex.Message;
                errorModel.ErrorDetail = ex.ToString();
                LogHelper.Current.WriteLogs(ex.ToString(), "SystemService.sp_get_HistoryCheckin_By_HistoryId", UserName);
            }

            return(ret);
        }
Exemple #2
0
 public void SaveInformationCheckInOut(HistoryCheckInModel historyCheckInModel, string userName)
 {
     try
     {
         DBHelper db = new DBHelper(GlobalInfo.PKG_TMS_CHECKINOUT + ".sp_saveInformation_CheckInOut", userName)
                       .addParamOutput("oResult")
                       .addParam("pUserName", userName)
                       .addParam("pJson", JsonHelper.Serialize(historyCheckInModel))
                       .ExecuteStore();
     }
     catch (Exception ex)
     {
         LogHelper.Current.WriteLogs(ex.ToString(), "SystemService.SaveInformationCheckInOut", userName);
         throw new Exception(ex.ToString());
     }
 }
Exemple #3
0
        public ActionResult EditNote([Bind(Include = "HistoryId,NoteCheckIn,NoteCheckOut,Note")] HistoryCheckInModel historyCheckInModel, int IsCheckOut)
        {
            var historyData = SystemService.Current.GetHistoryCheckInByHistoryId(historyCheckInModel.HistoryId, SharedContext.Current.LoggedProfile.UserName, out ErrorResult);

            if (historyData == null)
            {
                ModelState.AddModelError("", "Dữ liệu này không tồn tại!");
            }
            else if (historyData.UserName != SharedContext.Current.LoggedProfile.UserName)
            {
                ModelState.AddModelError("", "Bạn không có quyền chỉnh sửa dữ liệu này!");
            }
            if (ModelState.IsValid)
            {
                historyCheckInModel.UserName = LoginProfile.UserName;
                ErrorResult = new ErrorModel();
                try
                {
                    if (IsCheckOut == 1)
                    {
                        SystemService.Current.CheckOut(historyData.UserName, historyData.DateCheckIn_DTime);
                        SystemService.Current.EditNote(historyCheckInModel);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        SystemService.Current.EditNote(historyCheckInModel);
                    }
                    TempData["SuccessMessage"] = "Cập nhật ghi chú thành công.";
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return(View("Index"));
        }
Exemple #4
0
 public ActionResult SaveCheckInOut(FormCollection frm)
 {
     if (ModelState.IsValid)
     {
         var historyCheckInModel = new HistoryCheckInModel()
         {
             DateCheckIn_DTime  = frm["DateCheckIn"].ToString(),
             DateCheckOut_DTime = frm["DateCheckOut"].ToString(),
             HistoryId          = int.Parse(frm["HistoryId"].ToString()),
             NoteCheckIn        = frm["NoteCheckIn"].ToString(),
             NoteCheckOut       = frm["NoteCheckOut"].ToString(),
             UserName           = frm["UserName"],
             Note = frm["Note"].ToString()
         };
         ErrorResult = new ErrorModel();
         try
         {
             DateTime dateCheckIn, dateCheckOut;
             if (!string.IsNullOrEmpty(historyCheckInModel.DateCheckIn_DTime))
             {
                 historyCheckInModel.DateCheckIn_DTime = historyCheckInModel.DateCheckIn_DTime.Trim();
                 if (DateTime.TryParseExact(historyCheckInModel.DateCheckIn_DTime, "dd-MM-yyyy HH:mm", null, System.Globalization.DateTimeStyles.None, out dateCheckIn))
                 {
                     historyCheckInModel.DateCheckIn_DTime = dateCheckIn.ToString("ddMMyyyyHHmmss");
                 }
                 else if (DateTime.TryParseExact(historyCheckInModel.DateCheckIn_DTime, "dd-MM-yyyy HH:m", null, System.Globalization.DateTimeStyles.None, out dateCheckIn))
                 {
                     historyCheckInModel.DateCheckIn_DTime = dateCheckIn.ToString("ddMMyyyyHHmmss");
                 }
                 else if (DateTime.TryParseExact(historyCheckInModel.DateCheckIn_DTime, "dd-MM-yyyy H:mm", null, System.Globalization.DateTimeStyles.None, out dateCheckIn))
                 {
                     historyCheckInModel.DateCheckIn_DTime = dateCheckIn.ToString("ddMMyyyyHHmmss");
                 }
                 else if (DateTime.TryParseExact(historyCheckInModel.DateCheckIn_DTime, "dd-MM-yyyy H:m", null, System.Globalization.DateTimeStyles.None, out dateCheckIn))
                 {
                     historyCheckInModel.DateCheckIn_DTime = dateCheckIn.ToString("ddMMyyyyHHmmss");
                 }
                 else
                 {
                     return(Content("Thời gian cần đúng định dạng dd-MM-yyyy HH:mm"));
                 }
             }
             if (!string.IsNullOrEmpty(historyCheckInModel.DateCheckOut_DTime))
             {
                 historyCheckInModel.DateCheckOut_DTime = historyCheckInModel.DateCheckOut_DTime.Trim();
                 if (DateTime.TryParseExact(historyCheckInModel.DateCheckOut_DTime, "dd-MM-yyyy HH:mm", null, System.Globalization.DateTimeStyles.None, out dateCheckOut))
                 {
                     historyCheckInModel.DateCheckOut_DTime = dateCheckOut.ToString("ddMMyyyyHHmmss");
                 }
                 else if (DateTime.TryParseExact(historyCheckInModel.DateCheckOut_DTime, "dd-MM-yyyy HH:m", null, System.Globalization.DateTimeStyles.None, out dateCheckOut))
                 {
                     historyCheckInModel.DateCheckOut_DTime = dateCheckOut.ToString("ddMMyyyyHHmmss");
                 }
                 else if (DateTime.TryParseExact(historyCheckInModel.DateCheckOut_DTime, "dd-MM-yyyy H:mm", null, System.Globalization.DateTimeStyles.None, out dateCheckOut))
                 {
                     historyCheckInModel.DateCheckOut_DTime = dateCheckOut.ToString("ddMMyyyyHHmmss");
                 }
                 else if (DateTime.TryParseExact(historyCheckInModel.DateCheckOut_DTime, "dd-MM-yyyy H:m", null, System.Globalization.DateTimeStyles.None, out dateCheckOut))
                 {
                     historyCheckInModel.DateCheckOut_DTime = dateCheckOut.ToString("ddMMyyyyHHmmss");
                 }
                 else
                 {
                     return(Content("Thời gian cần đúng định dạng dd-MM-yyyy HH:mm"));
                 }
             }
             SystemService.Current.SaveInformationCheckInOut(historyCheckInModel, LoginProfile.UserName);
             return(Content("1"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
             return(Content(ex.Message));
         }
     }
     return(Content("Có lỗi dữ liệu không hợp lệ"));
 }