/// <summary> /// 设置实体 /// </summary> /// <param name="piStaffOrganizeEntity">实体</param> private void SetEntity(SQLBuilder sqlBuilder, PiStaffOrganizeEntity piStaffOrganizeEntity) { sqlBuilder.SetValue(PiStaffOrganizeTable.FieldStaffId, piStaffOrganizeEntity.StaffId); sqlBuilder.SetValue(PiStaffOrganizeTable.FieldOrganizeId, piStaffOrganizeEntity.OrganizeId); sqlBuilder.SetValue(PiStaffOrganizeTable.FieldDescription, piStaffOrganizeEntity.Description); sqlBuilder.SetValue(PiStaffOrganizeTable.FieldDeleteMark, piStaffOrganizeEntity.DeleteMark); }
/// <summary> /// 添加员工 /// </summary> /// <param name="userInfo">用户</param> /// <param name="entity">实体</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回消息</param> /// <param name="organizeId">组织机构主键</param> /// <returns>主鍵</returns> public string Add(UserInfo userInfo, PiStaffEntity entity, out string statusCode, out string statusMessage, string organizeId = "") { string returnValue = string.Empty; string returnCode = string.Empty; string returnMessage = string.Empty; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.StaffService_AddStaff); ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider => { var manager = new PiStaffManager(dbProvider, userInfo); returnValue = manager.Add(entity, out returnCode); returnMessage = manager.GetStateMessage(returnCode); if (returnValue.Length > 0 && returnCode == StatusCode.OKAdd.ToString() && !string.IsNullOrEmpty(organizeId.Trim())) { var staffOrganizeEntity = new PiStaffOrganizeEntity { StaffId = BusinessLogic.ConvertToString(returnValue), OrganizeId = BusinessLogic.ConvertToString(organizeId), Enabled = 1, DeleteMark = 0 }; var staffOrganizeManager = new PiStaffOrganizeManager(dbProvider, userInfo); staffOrganizeManager.Add(staffOrganizeEntity); } }); statusCode = returnCode; statusMessage = returnMessage; return(returnValue); }
/// <summary> /// 更新实体 /// </summary> /// <param name="piStaffOrganizeEntity">实体</param> public int UpdateEntity(PiStaffOrganizeEntity piStaffOrganizeEntity) { var sqlBuilder = new SQLBuilder(DBProvider); sqlBuilder.BeginUpdate(this.CurrentTableName); this.SetEntity(sqlBuilder, piStaffOrganizeEntity); if (UserInfo != null) { sqlBuilder.SetValue(PiStaffOrganizeTable.FieldModifiedBy, UserInfo.RealName); sqlBuilder.SetValue(PiStaffOrganizeTable.FieldModifiedUserId, UserInfo.Id); } sqlBuilder.SetDBNow(PiStaffOrganizeTable.FieldModifiedOn); sqlBuilder.SetWhere(PiStaffOrganizeTable.FieldId, piStaffOrganizeEntity.Id); return(sqlBuilder.EndUpdate()); }
/// <summary> /// 添加 /// </summary> /// <param name="piStaffOrganizeEntity">实体</param> /// <returns>主键</returns> public string Add(PiStaffOrganizeEntity piStaffOrganizeEntity) { return(this.AddEntity(piStaffOrganizeEntity)); }
/// <summary> /// 添加实体 /// </summary> /// <param name="piStaffOrganizeEntity">实体</param> public string AddEntity(PiStaffOrganizeEntity piStaffOrganizeEntity) { var sequence = string.Empty; this.Identity = false; var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, PiStaffOrganizeTable.FieldId); if (!this.Identity) { if (string.IsNullOrEmpty(piStaffOrganizeEntity.Id)) { sequence = BusinessLogic.NewGuid(); piStaffOrganizeEntity.Id = sequence; } sqlBuilder.SetValue(PiStaffOrganizeTable.FieldId, piStaffOrganizeEntity.Id); } else { if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (DBProvider.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(PiStaffOrganizeTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DBProvider.CurrentDbType == CurrentDbType.DB2) { sqlBuilder.SetFormula(PiStaffOrganizeTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (piStaffOrganizeEntity.Id == null) { if (string.IsNullOrEmpty(sequence)) { var sequenceManager = new CiSequenceManager(DBProvider, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } piStaffOrganizeEntity.Id = sequence; } sqlBuilder.SetValue(PiStaffOrganizeTable.FieldId, piStaffOrganizeEntity.Id); } } } this.SetEntity(sqlBuilder, piStaffOrganizeEntity); if (UserInfo != null) { sqlBuilder.SetValue(PiStaffOrganizeTable.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(PiStaffOrganizeTable.FieldCreateBy, UserInfo.RealName); } sqlBuilder.SetDBNow(PiStaffOrganizeTable.FieldCreateOn); if (UserInfo != null) { sqlBuilder.SetValue(PiStaffOrganizeTable.FieldModifiedBy, UserInfo.RealName); sqlBuilder.SetValue(PiStaffOrganizeTable.FieldModifiedUserId, UserInfo.Id); } sqlBuilder.SetDBNow(PiStaffOrganizeTable.FieldModifiedOn); if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access)) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 更新 /// </summary> /// <param name="piStaffOrganizeEntity">实体</param> public int Update(PiStaffOrganizeEntity piStaffOrganizeEntity) { return(this.UpdateEntity(piStaffOrganizeEntity)); }
/// <summary> /// 添加 /// </summary> /// <param name="piStaffOrganizeEntity">实体</param> /// <param name="identity">自增量方式</param> /// <param name="returnId">返回主键</param> /// <returns>主键</returns> public string Add(PiStaffOrganizeEntity piStaffOrganizeEntity, bool identity, bool returnId) { this.Identity = identity; this.ReturnId = returnId; return(this.AddEntity(piStaffOrganizeEntity)); }