예제 #1
0
        public SYS_User SelectSYS_User(int ID)
        {
            SYS_User     sys_user   = new SYS_User();
            DbDataReader reader     = null;
            DbConnection connection = _DbHelper.CreateConnection(Common.ConnectionString);

            connection.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_ID, ID, false));

                reader = _DbHelper.ExecuteReader(connection, Common.DatabaseSchema + "[SYS_User_SelectById]", para.ToArray());
                if (reader.HasRows && reader.Read())
                {
                    SYS_UserDataAccess.SetSYS_UserInfo(reader, ref sys_user);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_UserDataAccess.SelectById: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                connection.Close();
            }
            return(sys_user);
        }
예제 #2
0
        public SYS_User SelectUserByUserName(string connectionString, string UserName)
        {
            SYS_ConfigConnectionDataAccess connectionDataAccess = new SYS_ConfigConnectionDataAccess();

            connectionString = connectionDataAccess.DecryptSYS_ConfigConnection(connectionString);
            SYS_User     sysUser    = new SYS_User();
            DbDataReader reader     = null;
            DbConnection connection = _DbHelper.CreateConnection(connectionString);

            connection.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_USERNAME, UserName, false));
                reader = _DbHelper.ExecuteReader(connection, Common.DatabaseSchema + "[SYS_User_SelectByUserName]", para.ToArray());
                if (reader.HasRows && reader.Read())
                {
                    SYS_UserDataAccess.SetSYS_UserInfo(reader, ref sysUser);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_UserDataAccess.SelectByUserName: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                connection.Close();
            } return(sysUser);
        }
예제 #3
0
        private static void SetListSYS_UserInfo(ref DbDataReader reader, ref List <SYS_User> sys_users)
        {
            SYS_User sys_user = null;

            while (reader.Read())
            {
                sys_user = new SYS_User();
                SYS_UserDataAccess.SetSYS_UserInfo(reader, ref sys_user);
                sys_users.Add(sys_user);
            }
        }
예제 #4
0
        private static void SetListSYS_UserInfoAll(ref DbDataReader reader, ref List <SYS_User> sys_users)
        {
            SYS_User            sys_user;
            SYS_RolesDataAccess sysRolesDataAccess = new SYS_RolesDataAccess();

            while (reader.Read())
            {
                sys_user = new SYS_User();
                SYS_UserDataAccess.SetSYS_UserInfo(reader, ref sys_user);
                sys_user.Roles = sysRolesDataAccess.GetRolesByUser(sys_user.ID);
                sys_users.Add(sys_user);
            }
        }
예제 #5
0
        public SYS_User SelectUserByUserNameOffLine(string userName)
        {
            SYS_User     sys_user   = new SYS_User();
            DbDataReader reader     = null;
            DbConnection connection = _DbHelper.CreateConnection(Common.ConnectionString);

            connection.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_USERNAME, userName, false));

                reader = _DbHelper.ExecuteReader(connection, Common.DatabaseSchema + "[SYS_User_SelectByUserNameOffLine]", para.ToArray());
                if (reader.HasRows && reader.Read())
                {
                    SYS_UserDataAccess.SetSYS_UserInfo(reader, ref sys_user);
                    //SYS_Staff s = new SYS_Staff();
                    //s = sysStaffDataAccess.SelectSYS_Staff(sys_user.ID, connection);
                    //sys_user.IDOrganization = s.OrganizationId;
                    //SYS_OrganizationDataAccess sysOrganizationDataAccess = new SYS_OrganizationDataAccess();
                    //sys_user.Organization = sysOrganizationDataAccess.SelectSYS_Organization(connection, s.OrganizationId);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_UserDataAccess.SelectUserByUserNameOffLine: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                connection.Close();
            }
            return(sys_user);
        }