Exemple #1
0
 public string UpdateSingleCRUDData(SingleCRUDModel singleCRUDDataModel)
 {
     try
     {
         SingleCRUD singleCRUD = (from single in _db.SingleCRUD
                                  where single.Id == singleCRUDDataModel.Id
                                  select single).FirstOrDefault();
         //查無資料,修改失敗
         if (singleCRUD == null)
         {
             return("查無此修改資料,請確認人員編號是否異動或刪除");
         }
         _db.SingleCRUD.Attach(singleCRUD);
         singleCRUD.Name       = singleCRUDDataModel.Name;
         singleCRUD.Headcount  = singleCRUDDataModel.HeadCount;
         singleCRUD.Dtype      = singleCRUDDataModel.Dtype;
         singleCRUD.Upuser     = "******";
         singleCRUD.Updatetime = DateTime.Now;
         singleCRUD.Cruser     = "******";
         singleCRUD.Crdatetime = DateTime.Now;
         _db.SaveChanges();
         return("true");
     }
     catch (Exception ex)
     {
         return("false");
     }
 }
Exemple #2
0
 public string UpdateSingleCRUDData(SingleCRUDModel singleCRUDDataModel)
 {
     try
     {
         Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Info, LogManagement.LogAction.SYS_FunctionStart, LogManagement.SystemName.基本作業, "開始修改一筆SingleCRUD資料", singleCRUDDataModel, null);
         SingleCRUD singleCRUD = (from single in _db.SingleCRUD
                                  where single.Id == singleCRUDDataModel.Id
                                  select single).FirstOrDefault();
         //查無資料,修改失敗
         if (singleCRUD == null)
         {
             return("查無此修改資料,請確認人員編號是否異動或刪除");
         }
         _db.SingleCRUD.Attach(singleCRUD);
         singleCRUD.Name       = singleCRUDDataModel.Name;
         singleCRUD.Headcount  = singleCRUDDataModel.HeadCount;
         singleCRUD.Dtype      = singleCRUDDataModel.Dtype;
         singleCRUD.Upuser     = "******";
         singleCRUD.Updatetime = DateTime.Now;
         singleCRUD.Cruser     = "******";
         singleCRUD.Crdatetime = DateTime.Now;
         _db.SaveChanges();
         Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Error, LogManagement.LogAction.SYS_FunctionEnd, LogManagement.SystemName.基本作業, "新增一筆SingleCRUD資料結束", singleCRUDDataModel.Id, null);
         return("true");
     }
     catch (Exception ex)
     {
         Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Info, LogManagement.LogAction.Error_FunctionError, LogManagement.SystemName.基本作業, "新增一筆SingleCRUD資料,發生錯誤", singleCRUDDataModel, ex);
         return("false");
     }
 }
 /// <summary>
 /// 修改資料
 /// </summary>
 /// <returns></returns>
 public JsonResult UpdateSingleCRUDData(SingleCRUDModel singleCRUDDataModel)
 {
     try
     {
         //判斷PKEY是否有填寫
         if (string.IsNullOrEmpty(singleCRUDDataModel.Id))
         {
             return(Json(new { result = "false" }));
         }
         var result = _service.UpdateSingleCRUDData(singleCRUDDataModel);
         return(Json(new { result = result }));
     }
     catch (Exception ex)
     {
         return(Json(new { result = "false" }));
     }
 }
 /// <summary>
 /// 修改資料
 /// </summary>
 /// <returns></returns>
 public JsonResult UpdateSingleCRUDData(SingleCRUDModel singleCRUDDataModel)
 {
     try
     {
         //判斷PKEY是否有填寫
         if (string.IsNullOrEmpty(singleCRUDDataModel.Id))
         {
             Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Error, LogManagement.LogAction.Error_NullException, LogManagement.SystemName.基本作業, "傳入修改參數的Pkey為Null", singleCRUDDataModel, null);
             return(Json(new { result = "false" }));
         }
         Log.LogInfoWriter(userName, LogManagement.LogType.OP, LogManagement.EventLevel.Info, LogManagement.LogAction.USER_Action_Update, LogManagement.SystemName.基本作業, "使用者修改一筆資料", singleCRUDDataModel, null);
         Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Info, LogManagement.LogAction.SYS_FunctionStart, LogManagement.SystemName.基本作業, "開始修改一筆資料", singleCRUDDataModel, null);
         var result = _service.UpdateSingleCRUDData(singleCRUDDataModel);
         Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Info, LogManagement.LogAction.SYS_FunctionEnd, LogManagement.SystemName.基本作業, "修改一筆資料結束", singleCRUDDataModel, null);
         return(Json(new { result = result }));
     }
     catch (Exception ex)
     {
         Log.LogInfoWriter(userName, LogManagement.LogType.AP, LogManagement.EventLevel.Error, LogManagement.LogAction.Error_FunctionError, LogManagement.SystemName.基本作業, "修改一筆資料發生錯誤", singleCRUDDataModel, ex);
         return(Json(new { result = "false" }));
     }
 }