/// <summary> /// 设置实体 /// </summary> /// <param name="sqlBuilder">Sql语句生成器</param> /// <param name="userControlsEntity">实体</param> private void SetEntity(SQLBuilder sqlBuilder, UserControlsEntity userControlsEntity) { sqlBuilder.SetValue(UserControlsTable.FieldFullName, userControlsEntity.FullName); sqlBuilder.SetValue(UserControlsTable.FieldPath, userControlsEntity.Path); sqlBuilder.SetValue(UserControlsTable.FieldFormName, userControlsEntity.FormName); sqlBuilder.SetValue(UserControlsTable.FieldAssemblyName, userControlsEntity.AssemblyName); sqlBuilder.SetValue(UserControlsTable.FieldControlId, userControlsEntity.ControlId); sqlBuilder.SetValue(UserControlsTable.FieldDescription, userControlsEntity.Description); sqlBuilder.SetValue(UserControlsTable.FieldType, userControlsEntity.Type); sqlBuilder.SetValue(UserControlsTable.FieldEnabled, userControlsEntity.Enabled); }
/// <summary> /// 修改一个子表单 /// </summary> /// <param name="userInfo">用户</param> /// <param name="entity">子表单实体</param> /// <returns>大于0成功</returns> public int UpdateUserControl(UserInfo userInfo, UserControlsEntity entity) { var returnValue = -1; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.WorkFlowUserControlService_UpdateUserControl); ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, dbProvider => { var manager = new UserControlsManager(dbProvider, userInfo); returnValue = manager.UpdateUserControl(entity); }); return(returnValue); }
/// <summary> /// 更新实体 /// </summary> /// <param name="userControlsEntity">实体</param> public int UpdateEntity(UserControlsEntity userControlsEntity) { var sqlBuilder = new SQLBuilder(DBProvider); sqlBuilder.BeginUpdate(this.CurrentTableName); this.SetEntity(sqlBuilder, userControlsEntity); if (UserInfo != null) { sqlBuilder.SetValue(UserControlsTable.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(UserControlsTable.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(UserControlsTable.FieldModifiedOn); sqlBuilder.SetWhere(UserControlsTable.FieldId, userControlsEntity.Id); return(sqlBuilder.EndUpdate()); }
/// <summary> /// 修改一个子表单 /// </summary> /// <param name="entity">子表单实体</param> /// <returns>大于0操作成功</returns> public int UpdateUserControl(UserControlsEntity entity) { int returnInt = -1; if (entity.Id.Trim().Length == 0 || entity.Id == null) { throw new Exception("UpdateUserControl方法错误,Id 不能为空!"); } if (entity.FullName.Trim().Length == 0 || entity.FullName == null) { throw new Exception("InsertUserControl方法错误,FullName 不能为空!"); } try { returnInt = this.UpdateEntity(entity); } catch (Exception ex) { throw ex; } return(returnInt); }
/// <summary> /// 新增子表单 /// </summary> /// <param name="entity">子表单实体</param> /// <returns>增加成功返回实体主键</returns> public string InsertUserControl(UserControlsEntity entity) { string returnString = string.Empty; if (entity.Id.Trim().Length == 0 || entity.Id == null) { throw new Exception("InsertUserControl方法错误,Id 不能为空!"); } if (entity.FullName.Trim().Length == 0 || entity.FullName == null) { throw new Exception("InsertUserControl方法错误,FullName 不能为空!"); } try { returnString = this.AddEntity(entity); } catch (Exception ex) { throw ex; } return(returnString); }
/// <summary> /// 添加实体 /// </summary> /// <param name="userControlsEntity">实体</param> public string AddEntity(UserControlsEntity userControlsEntity) { var sequence = string.Empty; this.Identity = false; if (!string.IsNullOrEmpty(userControlsEntity.Id)) { sequence = userControlsEntity.Id.ToString(CultureInfo.InvariantCulture); } var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, UserControlsTable.FieldId); if (!this.Identity) { if (string.IsNullOrEmpty(userControlsEntity.Id)) { sequence = BusinessLogic.NewGuid(); userControlsEntity.Id = sequence; } sqlBuilder.SetValue(UserControlsTable.FieldId, userControlsEntity.Id); } else { if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (DBProvider.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(UserControlsTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DBProvider.CurrentDbType == CurrentDbType.DB2) { sqlBuilder.SetFormula(UserControlsTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (string.IsNullOrEmpty(userControlsEntity.Id)) { if (string.IsNullOrEmpty(sequence)) { var sequenceManager = new CiSequenceManager(DBProvider, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } userControlsEntity.Id = sequence; } sqlBuilder.SetValue(UserControlsTable.FieldId, userControlsEntity.Id); } } } this.SetEntity(sqlBuilder, userControlsEntity); if (UserInfo != null) { sqlBuilder.SetValue(UserControlsTable.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(UserControlsTable.FieldCreateBy, UserInfo.RealName); sqlBuilder.SetValue(UserControlsTable.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(UserControlsTable.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(UserControlsTable.FieldCreateOn); sqlBuilder.SetDBNow(UserControlsTable.FieldModifiedOn); if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access)) { sequence = sqlBuilder.EndInsert().ToString(CultureInfo.InvariantCulture); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 更新 /// </summary> /// <param name="userControlsEntity">实体</param> public int Update(UserControlsEntity userControlsEntity) { return(this.UpdateEntity(userControlsEntity)); }
/// <summary> /// 添加 /// </summary> /// <param name="userControlsEntity">实体</param> /// <param name="identity">自增量方式</param> /// <param name="returnId">返回主键</param> /// <returns>主键</returns> public string Add(UserControlsEntity userControlsEntity, bool identity, bool returnId) { this.Identity = identity; this.ReturnId = returnId; return(this.AddEntity(userControlsEntity)); }
/// <summary> /// 添加 /// </summary> /// <param name="userControlsEntity">实体</param> /// <returns>主键</returns> public string Add(UserControlsEntity userControlsEntity) { return(this.AddEntity(userControlsEntity)); }