예제 #1
0
 /// <summary>
 /// 载入数据
 /// </summary>
 /// <param name="reader">数据读取器</param>
 /// <param name="entity">读取数据的实体</param>
 public override void SimpleLoad(MySqlDataReader reader, OrganizePositionData entity)
 {
     using (new EditScope(entity.__EntityStatus, EditArrestMode.All, false))
     {
         entity._id = (int)reader.GetInt32(0);
         if (!reader.IsDBNull(1))
         {
             entity._position = reader.GetString(1).ToString();
         }
         if (!reader.IsDBNull(2))
         {
             entity._role = reader.GetString(2).ToString();
         }
         if (!reader.IsDBNull(3))
         {
             entity._department = reader.GetString(3).ToString();
         }
         if (!reader.IsDBNull(4))
         {
             entity._memo = reader.GetString(4).ToString();
         }
         if (!reader.IsDBNull(5))
         {
             entity._datastate = (DataStateType)reader.GetInt32(5);
         }
         entity._isfreeze = (bool)reader.GetBoolean(6);
         if (!reader.IsDBNull(7))
         {
             entity._auditstate = (AuditStateType)reader.GetInt32(7);
         }
     }
 }
예제 #2
0
 /// <summary>
 ///     保存完成后期处理(Insert或Update)
 /// </summary>
 /// <param name="entity"></param>
 protected sealed override void OnDataSaved(OrganizePositionData entity)
 {
     using (var proxy = new RedisProxy(RedisProxy.DbComboCache))
     {
         proxy.RemoveKey(treeKey);
         proxy.RemoveKey(comboKey);
     }
 }
예제 #3
0
 /// <summary>
 /// 读取Form传过来的数据
 /// </summary>
 /// <param name="data">数据</param>
 /// <param name="convert">转化器</param>
 protected void DefaultReadFormData(OrganizePositionData data, FormConvert convert)
 {
     //职位
     data.Position = convert.ToString("Position");
     //数据
     data.RoleId         = convert.ToInteger("RoleId");
     data.OrganizationId = convert.ToInteger("OrganizationId");
     //备注
     data.Memo = convert.ToString("Memo");
 }
예제 #4
0
 /// <summary>
 /// 载入数据
 /// </summary>
 /// <param name="reader">数据读取器</param>
 /// <param name="entity">读取数据的实体</param>
 protected sealed override void LoadEntity(MySqlDataReader reader, OrganizePositionData entity)
 {
     using (new EditScope(entity.__EntityStatus, EditArrestMode.All, false))
     {
         entity._id = (int)reader.GetInt32(0);
         if (!reader.IsDBNull(1))
         {
             entity._position = reader.GetString(1).ToString();
         }
         entity._roleid = (int)reader.GetInt32(2);
         if (!reader.IsDBNull(3))
         {
             entity._role = reader.GetString(3).ToString();
         }
         entity._organizationid = (int)reader.GetInt32(4);
         if (!reader.IsDBNull(5))
         {
             entity._department = reader.GetString(5).ToString();
         }
         if (!reader.IsDBNull(6))
         {
             entity._orglevel = (int)reader.GetInt32(6);
         }
         if (!reader.IsDBNull(7))
         {
             entity._memo = reader.GetString(7).ToString();
         }
         if (!reader.IsDBNull(8))
         {
             entity._datastate = (DataStateType)reader.GetInt32(8);
         }
         entity._isfreeze = (bool)reader.GetBoolean(9);
         entity._authorid = (int)reader.GetInt32(10);
         if (!reader.IsDBNull(11))
         {
             try{ entity._adddate = reader.GetMySqlDateTime(11).Value; }catch {}
         }
         entity._lastreviserid = (int)reader.GetInt32(12);
         if (!reader.IsDBNull(13))
         {
             try{ entity._lastmodifydate = reader.GetMySqlDateTime(13).Value; }catch {}
         }
         if (!reader.IsDBNull(14))
         {
             entity._auditstate = (AuditStateType)reader.GetInt32(14);
         }
         entity._auditorid = (int)reader.GetInt32(15);
         if (!reader.IsDBNull(16))
         {
             try{ entity._auditdate = reader.GetMySqlDateTime(16).Value; }catch {}
         }
     }
 }
 public static EasyUiTreeNode CreateNode(OrganizePositionData data)
 {
     return(new EasyUiTreeNode
     {
         ID = data.Id,
         Icon = "icon-post",
         IsOpen = true,
         IsFolder = true,
         Attributes = "post",
         Text = data.Position,
         Title = data.Department + data.Position,
         Tag = data.OrganizationId.ToString()
     });
 }
예제 #6
0
 /// <summary>
 /// 设置插入数据的命令
 /// </summary>
 /// <param name="entity">实体对象</param>
 /// <param name="cmd">命令</param>
 /// <returns>返回真说明要取主键</returns>
 protected sealed override bool SetInsertCommand(OrganizePositionData entity, MySqlCommand cmd)
 {
     cmd.CommandText = InsertSqlCode;
     CreateFullSqlParameter(entity, cmd);
     return(true);
 }
예제 #7
0
 /// <summary>
 /// 设置更新数据的命令
 /// </summary>
 /// <param name="entity">实体对象</param>
 /// <param name="cmd">命令</param>
 protected sealed override void SetUpdateCommand(OrganizePositionData entity, MySqlCommand cmd)
 {
     cmd.CommandText = UpdateSqlCode;
     CreateFullSqlParameter(entity, cmd);
 }
예제 #8
0
        /// <summary>
        /// 设置插入数据的命令
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <param name="cmd">命令</param>
        /// <returns>返回真说明要取主键</returns>
        private void CreateFullSqlParameter(OrganizePositionData entity, MySqlCommand cmd)
        {
            //02:标识(Id)
            cmd.Parameters.Add(new MySqlParameter("Id", MySqlDbType.Int32)
            {
                Value = entity.Id
            });
            //03:职位(Position)
            var isNull    = string.IsNullOrWhiteSpace(entity.Position);
            var parameter = new MySqlParameter("Position", MySqlDbType.VarString, isNull ? 10 : (entity.Position).Length);

            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.Position;
            }
            cmd.Parameters.Add(parameter);
            //04:角色标识(RoleId)
            cmd.Parameters.Add(new MySqlParameter("RoleId", MySqlDbType.Int32)
            {
                Value = entity.RoleId
            });
            //05:角色(Role)
            isNull    = string.IsNullOrWhiteSpace(entity.Role);
            parameter = new MySqlParameter("Role", MySqlDbType.VarString, isNull ? 10 : (entity.Role).Length);
            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.Role;
            }
            cmd.Parameters.Add(parameter);
            //06:部门标识(OrganizationId)
            cmd.Parameters.Add(new MySqlParameter("OrganizationId", MySqlDbType.Int32)
            {
                Value = entity.OrganizationId
            });
            //07:部门(Department)
            isNull    = string.IsNullOrWhiteSpace(entity.Department);
            parameter = new MySqlParameter("Department", MySqlDbType.VarString, isNull ? 10 : (entity.Department).Length);
            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.Department;
            }
            cmd.Parameters.Add(parameter);
            //08:级别(OrgLevel)
            cmd.Parameters.Add(new MySqlParameter("OrgLevel", MySqlDbType.Int32)
            {
                Value = entity.OrgLevel
            });
            //09:备注(Memo)
            isNull    = string.IsNullOrWhiteSpace(entity.Memo);
            parameter = new MySqlParameter("Memo", MySqlDbType.Text, isNull ? 10 : (entity.Memo).Length);
            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.Memo;
            }
            cmd.Parameters.Add(parameter);
            //10:数据状态(DataState)
            cmd.Parameters.Add(new MySqlParameter("DataState", MySqlDbType.Int32)
            {
                Value = (int)entity.DataState
            });
            //11:数据是否已冻结(IsFreeze)
            cmd.Parameters.Add(new MySqlParameter("IsFreeze", MySqlDbType.Byte)
            {
                Value = entity.IsFreeze ? (byte)1 : (byte)0
            });
            //12:制作人(AuthorID)
            cmd.Parameters.Add(new MySqlParameter("AuthorID", MySqlDbType.Int32)
            {
                Value = entity.AuthorID
            });
            //13:制作时间(AddDate)
            isNull    = entity.AddDate.Year < 1900;
            parameter = new MySqlParameter("AddDate", MySqlDbType.DateTime);
            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.AddDate;
            }
            cmd.Parameters.Add(parameter);
            //14:最后修改者(LastReviserID)
            cmd.Parameters.Add(new MySqlParameter("LastReviserID", MySqlDbType.Int32)
            {
                Value = entity.LastReviserID
            });
            //15:最后修改日期(LastModifyDate)
            isNull    = entity.LastModifyDate.Year < 1900;
            parameter = new MySqlParameter("LastModifyDate", MySqlDbType.DateTime);
            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.LastModifyDate;
            }
            cmd.Parameters.Add(parameter);
            //16:审核状态(AuditState)
            cmd.Parameters.Add(new MySqlParameter("AuditState", MySqlDbType.Int32)
            {
                Value = (int)entity.AuditState
            });
            //17:审核人(AuditorId)
            cmd.Parameters.Add(new MySqlParameter("AuditorId", MySqlDbType.Int32)
            {
                Value = entity.AuditorId
            });
            //18:审核时间(AuditDate)
            isNull    = entity.AuditDate.Year < 1900;
            parameter = new MySqlParameter("AuditDate", MySqlDbType.DateTime);
            if (isNull)
            {
                parameter.Value = DBNull.Value;
            }
            else
            {
                parameter.Value = entity.AuditDate;
            }
            cmd.Parameters.Add(parameter);
        }
예제 #9
0
        /// <summary>
        /// 取得仅更新的SQL语句
        /// </summary>
        internal string GetModifiedSqlCode(OrganizePositionData data)
        {
            if (data.__EntityStatusNull || !data.__EntityStatus.IsModified)
            {
                return(";");
            }
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("UPDATE `tb_sys_organize_position` SET");
            //职位
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_Position] > 0)
            {
                sql.AppendLine("       `appellation` = ?Position");
            }
            //角色标识
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_RoleId] > 0)
            {
                sql.AppendLine("       `role_id` = ?RoleId");
            }
            //部门标识
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_OrganizationId] > 0)
            {
                sql.AppendLine("       `organization_id` = ?OrganizationId");
            }
            //备注
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_Memo] > 0)
            {
                sql.AppendLine("       `memo` = ?Memo");
            }
            //数据状态
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_DataState] > 0)
            {
                sql.AppendLine("       `data_state` = ?DataState");
            }
            //数据是否已冻结
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_IsFreeze] > 0)
            {
                sql.AppendLine("       `is_freeze` = ?IsFreeze");
            }
            //制作人
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_AuthorID] > 0)
            {
                sql.AppendLine("       `author_id` = ?AuthorID");
            }
            //制作时间
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_AddDate] > 0)
            {
                sql.AppendLine("       `add_date` = ?AddDate");
            }
            //最后修改者
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_LastReviserID] > 0)
            {
                sql.AppendLine("       `last_reviser_id` = ?LastReviserID");
            }
            //最后修改日期
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_LastModifyDate] > 0)
            {
                sql.AppendLine("       `last_modify_date` = ?LastModifyDate");
            }
            //审核状态
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_AuditState] > 0)
            {
                sql.AppendLine("       `audit_state` = ?AuditState");
            }
            //审核人
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_AuditorId] > 0)
            {
                sql.AppendLine("       `auditor_id` = ?AuditorId");
            }
            //审核时间
            if (data.__EntityStatus.ModifiedProperties[OrganizePositionData.Real_AuditDate] > 0)
            {
                sql.AppendLine("       `audit_date` = ?AuditDate");
            }
            sql.Append(" WHERE `id` = ?Id;");
            return(sql.ToString());
        }