/// <summary> /// 保存实体数据 /// </summary> /// <param name="keyValue">主键</param> /// <param name="entity">数据实体</param> /// <param name="formModuleContentEntity">表单内容数据</param> /// <returns></returns> public int SaveEntity(string keyValue, FormModuleRelationEntity entity, Form_ModuleContentEntity formModuleContentEntity) { var db = this.BaseRepository().BeginTrans(); try { var expression = LinqExtensions.True <Form_ModuleContentEntity>(); expression = expression.And(t => t.F_FrmId == entity.F_FrmId && t.F_FrmVersion == entity.F_FrmVersion); Form_ModuleContentEntity form_ModuleContentEntity = db.FindEntity <Form_ModuleContentEntity>(expression); if (form_ModuleContentEntity == null) { formModuleContentEntity.Create(); db.Insert(formModuleContentEntity); entity.F_ModuleContentId = formModuleContentEntity.F_Id; } else { entity.F_ModuleContentId = form_ModuleContentEntity.F_Id; } if (string.IsNullOrEmpty(keyValue)) { entity.Create(); db.Insert(entity); } else { entity.Modify(keyValue); db.Update(entity); } db.Commit(); return(1); } catch (Exception) { db.Rollback(); throw; } }
/// <summary> /// 保存实体数据(关联功能模块菜单) /// </summary> /// <param name="keyValue">主键Id</param> /// <param name="entity">表单关联实体</param> /// <param name="moduleEntity">系统功能模板实体</param> /// <param name="formModuleContentEntity">表单内容数据</param> /// <returns></returns> public void SaveEntity(string keyValue, FormModuleRelationEntity entity, ModuleEntity moduleEntity, Form_ModuleContentEntity formModuleContentEntity) { IRepository db = this.BaseRepository().BeginTrans(); try { var expression = LinqExtensions.True <Form_ModuleContentEntity>(); expression = expression.And(t => t.F_FrmId == entity.F_FrmId && t.F_FrmVersion == entity.F_FrmVersion); Form_ModuleContentEntity form_ModuleContentEntity = db.FindEntity <Form_ModuleContentEntity>(expression); if (form_ModuleContentEntity == null) { formModuleContentEntity.Create(); db.Insert(formModuleContentEntity); entity.F_ModuleContentId = formModuleContentEntity.F_Id; } else { entity.F_ModuleContentId = form_ModuleContentEntity.F_Id; } if (string.IsNullOrEmpty(keyValue)) { entity.Create(); moduleEntity.Create(); db.Insert(moduleEntity); entity.F_ObjectId = moduleEntity.F_ModuleId; entity.F_ObjectName = moduleEntity.F_FullName; moduleEntity.F_UrlAddress = moduleEntity.F_UrlAddress + "?Id=" + entity.F_Id; db.Insert(entity); } else { entity.Modify(keyValue); moduleEntity.Modify(entity.F_ObjectId); db.Update(moduleEntity); entity.F_ObjectName = moduleEntity.F_FullName; moduleEntity.F_UrlAddress = moduleEntity.F_UrlAddress + "?Id=" + entity.F_Id; db.Update(entity); } db.Delete <ModuleButtonEntity>(t => t.F_ModuleId.Equals(moduleEntity.F_ModuleId)); ModuleButtonEntity moduleButtonrReplace = new ModuleButtonEntity(); moduleButtonrReplace.F_ModuleId = moduleEntity.F_ModuleId; moduleButtonrReplace.F_EnCode = "lr-replace"; moduleButtonrReplace.F_FullName = "刷新"; moduleButtonrReplace.F_SortCode = 0; moduleButtonrReplace.F_ParentId = "0"; moduleButtonrReplace.Create(); db.Insert(moduleButtonrReplace); ModuleButtonEntity moduleButtonrAdd = new ModuleButtonEntity(); moduleButtonrAdd.F_ModuleId = moduleEntity.F_ModuleId; moduleButtonrAdd.F_EnCode = "lr-add"; moduleButtonrAdd.F_FullName = "新增"; moduleButtonrAdd.F_SortCode = 1; moduleButtonrAdd.F_ActionAddress = "/FormManage/FormModule/CustmerFormForm"; moduleButtonrAdd.F_ParentId = "0"; moduleButtonrAdd.Create(); db.Insert(moduleButtonrAdd); ModuleButtonEntity moduleButtonrEdit = new ModuleButtonEntity(); moduleButtonrEdit.F_ModuleId = moduleEntity.F_ModuleId; moduleButtonrEdit.F_EnCode = "lr-edit"; moduleButtonrEdit.F_FullName = "编辑"; moduleButtonrEdit.F_SortCode = 2; moduleButtonrEdit.F_ActionAddress = "/FormManage/FormModule/CustmerFormForm"; moduleButtonrEdit.F_ParentId = "0"; moduleButtonrEdit.Create(); db.Insert(moduleButtonrEdit); ModuleButtonEntity moduleButtonrDelete = new ModuleButtonEntity(); moduleButtonrDelete.F_ModuleId = moduleEntity.F_ModuleId; moduleButtonrDelete.F_EnCode = "lr-delete"; moduleButtonrDelete.F_FullName = "删除"; moduleButtonrDelete.F_SortCode = 3; moduleButtonrDelete.F_ActionAddress = "/FormManage/FormModule/CustmerFormRemove"; moduleButtonrDelete.F_ParentId = "0"; moduleButtonrDelete.Create(); db.Insert(moduleButtonrDelete); db.Commit(); } catch { db.Rollback(); throw; } }