/// <summary> /// 保存表单 /// </summary> /// <param name="entity">表单模板实体类</param> /// <param name="keyValue">主键</param> /// <returns></returns> public int SaveEntity(string keyValue, FormModuleEntity entity) { try { if (string.IsNullOrEmpty(keyValue)) { entity.F_Version = "V" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); entity.Create(); return(this.BaseRepository().Insert(entity)); } else { if (entity.F_EnabledMark == 1 && !string.IsNullOrEmpty(entity.F_FrmContent)) { FormModuleEntity one = this.BaseRepository().FindEntity <FormModuleEntity>(keyValue); if (one.F_FrmContent != entity.F_FrmContent)//如果和原来的表单数据不一样产生的版本号 { entity.F_Version = "V" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); } } entity.Modify(keyValue); return(this.BaseRepository().Update(entity)); } } catch (Exception) { throw; } }
/// <summary> /// 更新表单模板状态(启用,停用) /// </summary> /// <param name="keyValue">主键</param> /// <param name="state">状态 1:启用;0.停用</param> public void UpdateState(string keyValue, int state) { try { FormModuleEntity entity = new FormModuleEntity(); entity.Modify(keyValue); entity.EnabledMark = state; this.BaseRepository().Update(entity); } catch (Exception) { throw; } }
/// <summary> /// 虚拟删除表单模块数据 /// </summary> /// <param name="keyValue">主键</param> public int VirtualRemoveEntity(string keyValue) { try { FormModuleEntity entity = new FormModuleEntity(); entity.Modify(keyValue); entity.F_DeleteMark = 1; return(this.BaseRepository().Update(entity)); } catch (Exception) { throw; } }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, FormModuleEntity entity) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); FormModuleContentEntity modelentity = new FormModuleContentEntity(); try { if (!string.IsNullOrEmpty(keyValue)) { //修改的时候判断下版本。同时修改日期,修改人处理下 FormModuleEntity entity1 = GetEntity(keyValue); modelentity.FrmVersion = entity1.Version; if (entity.EnabledMark == 3) { modelentity.FrmVersion = "cg"; } modelentity.FrmId = keyValue; modelentity.FrmContent = entity.FrmContent; FormModuleContentEntity modelentityold = contentservice.GetEntity(keyValue, entity1.Version); if (modelentityold.FrmContent != modelentity.FrmContent) { if (modelentity.FrmVersion == "cg") { modelentityold.FrmContent = modelentity.FrmContent; modelentityold.FrmVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff"); modelentity.FrmVersion = modelentityold.FrmVersion; db.Update <FormModuleContentEntity>(modelentityold); } else { modelentity.Create(); modelentity.FrmId = keyValue; modelentity.FrmVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff"); db.Insert <FormModuleContentEntity>(modelentity); } } else { modelentity.FrmVersion = modelentityold.FrmVersion; } entity.Modify(keyValue); entity.Version = modelentity.FrmVersion; db.Update <FormModuleEntity>(entity); } else { //新增 //主表 entity.Create(); entity.Version = DateTime.Now.ToString("yyyyMMddHHmmssffff"); db.Insert(entity); //明细 modelentity.Create(); modelentity.FrmVersion = entity.Version; modelentity.FrmId = entity.FrmId; modelentity.FrmContent = entity.FrmContent; db.Insert(modelentity); } db.Commit(); } catch (Exception) { db.Rollback(); throw; } }