/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, FillRecordEntity entity) { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { entity.Create(); this.BaseRepository().Insert(entity); try { //更新主表检测时间、下次检测时间 IRepository db = new RepositoryFactory().BaseRepository(); FirefightingEntity fe = db.FindEntity <FirefightingEntity>(entity.EquipmentId); if (fe != null) { fe.LastFillDate = entity.FillDate; if (!string.IsNullOrEmpty(fe.FillPeriod.Value.ToString())) { fe.NextFillDate = entity.FillDate.Value.AddDays(fe.FillPeriod.Value); } db.Update <FirefightingEntity>(fe); } } catch { } } }
public object SaveFirefighting() { try { string res = ctx.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; //当前用户ID OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); string EquipmentId = dy.data.EquipmentId; string keyValue = dy.data.Id; string str = JsonConvert.SerializeObject(dy.data); FirefightingEntity entity = JsonConvert.DeserializeObject <FirefightingEntity>(str); //HttpFileCollection files = ctx.Request.Files;//上传的文件 firefightingbll.SaveForm(keyValue, entity); } catch (Exception) { return(new { code = -1, count = 0, info = "保存失败" }); } return(new { code = 0, count = 0, info = "保存成功" }); }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, FirefightingEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public void SaveFirefightingEntity(DetectionRecordEntity entity) { try { //更新主表维保时间、下次维保时间 IRepository db = new RepositoryFactory().BaseRepository(); FirefightingEntity fe = db.FindEntity <FirefightingEntity>(entity.EquipmentId); if (fe != null) { fe.DetectionDate = entity.DetectionDate; if (!string.IsNullOrEmpty(fe.DetectionPeriod.Value.ToString())) { fe.NextDetectionDate = entity.DetectionDate.Value.AddDays(fe.DetectionPeriod.Value); } fe.DetectionVerdict = entity.Conclusion; db.Update <FirefightingEntity>(fe); } } catch { } }