Beispiel #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);
        }
Beispiel #2
0
        public List <SYS_User> SelectAllSYS_User()
        {
            List <SYS_User> sys_user   = new List <SYS_User>();
            DbDataReader    reader     = null;
            DbConnection    connection = _DbHelper.CreateConnection(Common.ConnectionString);

            connection.Open();
            try
            {
                reader = _DbHelper.ExecuteReader(connection, Common.DatabaseSchema + "[SYS_User_SelectAll]", (DbParameter[])null);
                if (reader.HasRows)
                {
                    SYS_UserDataAccess.SetListSYS_UserInfo(ref reader, ref sys_user);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format(" SYS_UserDataAccess.SelectAll: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                connection.Close();
            }
            return(sys_user);
        }
Beispiel #3
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);
        }
        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);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        private static void SetSYS_LogInfo(DbDataReader reader, ref SYS_Log sys_log)
        {
            sys_log.ID          = int.Parse("0" + reader[FIELD_ID]);
            sys_log.UserId      = int.Parse("0" + reader[FIELD_USERID]);
            sys_log.FunctionId  = int.Parse("0" + reader[FIELD_FUNCTIONID]);
            sys_log.Action      = int.Parse("0" + reader[FIELD_ACTION]);
            sys_log.Description = "" + reader[FIELD_DESCRIPTION];
            DateTime Time = (DateTime)reader[FIELD_TIME];

            sys_log.Time     = Time != null ? (DateTime)Time : DateTime.Now;
            sys_log.IDBC     = int.Parse("0" + reader[FIELD_IDBC]);
            sys_log.PhanLoai = int.Parse("0" + reader[FIELD_PHANLOAI]);

            SYS_UserDataAccess sysUserDataAccess = new SYS_UserDataAccess();
            SYS_User           sysUser           = sysUserDataAccess.SelectSYS_User(sys_log.UserId);

            sys_log.Username = sysUser.Name;

            SYS_RightDataAccess sysRightDataAccess = new SYS_RightDataAccess();
            SYS_Right           sysRight           = sysRightDataAccess.SelectSYS_Right(sys_log.FunctionId);

            sys_log.FuncName = sysRight.FuncName;
        }
Beispiel #7
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);
        }