Example #1
0
        public static SinoUser GetNoRegisterUserByUserName(string _name)
        {
            SinoUser _su = new SinoUser();

            using (SqlConnection cn = SqlHelper.OpenConnection())
            {
                SqlCommand _cmd = new SqlCommand(SQL_GetNoRegisterUserByUserName, cn);
                _cmd.Parameters.Add(":LOGONNAME", _name);

                using (SqlDataReader dr = _cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        _su.LoginName   = _name;
                        _su.IsSignOn    = true;
                        _su.Dwdm        = dr.IsDBNull(4) ? "" : dr.GetString(4);
                        _su.DwID        = dr.IsDBNull(3) ? "" : dr.GetDecimal(3).ToString();
                        _su.DwName      = dr.IsDBNull(5) ? "" : dr.GetString(5);
                        _su.UserID      = dr.IsDBNull(1) ? "" : dr.GetDecimal(1).ToString();
                        _su.UserName    = dr.IsDBNull(2) ? "" : dr.GetString(2);
                        _su.SecretLevel = 0;
                        _su.QxszJB      = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。
                    }

                    //取岗位信息
                    _su.Posts = new List <SinoPost>();
                    SinoPost _sp = new SinoPost("未注册用户岗位", "0", _su.DwID, _su.DwName, _su.Dwdm, "未注册用户岗位", 0, true);
                    _su.Posts.Add(_sp);
                    _sp.Rights      = C_GetGWInfo.GetRightsOfPost("-1", "");
                    _su.DefaultPost = _sp;
                    _su.CurrentPost = _sp;
                }
                cn.Close();
            }
            return(_su);
        }
Example #2
0
        /// <summary>
        /// 通过用户ID取用户信息
        /// </summary>
        /// <param name="_yhid"></param>
        /// <returns></returns>
        public static SinoUser GetUserInfoByYHID(string _yhid)
        {
            if (_yhid == "0")
            {
                return(C_GetUserInfo.GetAdminInfo());
            }
            SinoUser _su = new SinoUser();

            using (SqlConnection cn = SqlHelper.OpenConnection())
            {
                //取用户信息

                SqlCommand _cmd = new SqlCommand(SQL_GetUserInfoByYHID, cn);
                _cmd.Parameters.Add(":YHID", decimal.Parse(_yhid));
                DataTable      _yhdt    = new DataTable("YHTABLE");
                SqlDataAdapter _adapter = new SqlDataAdapter(_cmd);
                _adapter.Fill(_yhdt);

                if (_yhdt.Rows.Count < 1)
                {
                    //为未注册用户
                    //throw new Exception(string.Format("用户尚未在系统中注册!"));
                    return(C_GetUserInfo.GetNoRegisterUserByUserID(decimal.Parse(_yhid)));
                }

                DataRow _dr = _yhdt.Rows[0];
                _su.LoginName   = _dr["YHM"].ToString();
                _su.Dwdm        = _dr["DWDM"].ToString();
                _su.DwID        = _dr["DWID"].ToString();
                _su.DwName      = _dr["DWMC"].ToString();
                _su.UserID      = _yhid;
                _su.UserName    = _dr["XM"].ToString();
                _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString());
                _su.QxszJB      = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。

                //取岗位信息
                _su.Posts = C_GetGWInfo.Get_PostsByYHID(_su.UserID);
                foreach (SinoPost _sp in _su.Posts)
                {
                    _sp.Rights = C_GetGWInfo.GetRightsOfPost(_sp.PostID, "");
                    if (_sp.IsDefaultPost)
                    {
                        _su.DefaultPost = _sp;
                    }
                }
                if (_su.DefaultPost == null)
                {
                    if (_su.Posts.Count > 0)
                    {
                        _su.DefaultPost = (SinoPost)_su.Posts[0];
                    }
                    else
                    {
                        _su.DefaultPost = new SinoPost();
                    }
                }
                _su.CurrentPost = _su.DefaultPost;
                cn.Close();
            }
            return(_su);
        }
Example #3
0
        /// <summary>
        /// 通过用户登录名取用户信息
        /// </summary>
        /// <param name="_userName">用户登录名称</param>
        /// <returns></returns>
        public static SinoUser GetUserInfoByLoginName(string _userName)
        {
            if (_userName == "Administrator")
            {
                return(C_GetUserInfo.GetAdminInfo());
            }
            SinoUser _su = new SinoUser();

            using (SqlConnection cn = SqlHelper.OpenConnection())
            {
                //取用户信息

                SqlParameter[] _param =
                {
                    new SqlParameter(":YHM", SqlDbType.VarChar)
                };
                _param[0].Value = _userName;

                DataTable _yhdt = SqlHelper.FillDataTable(cn, CommandType.Text, SQL_GetUserInfoByLoginName, _param);

                if (_yhdt.Rows.Count < 1)
                {
                    //为未注册用户
                    throw new Exception(string.Format("用户尚未在系统中注册!"));
                }

                DataRow _dr = _yhdt.Rows[0];
                _su.LoginName   = _dr["YHM"].ToString();
                _su.Dwdm        = _dr["DWDM"].ToString();
                _su.DwID        = _dr["DWID"].ToString();
                _su.DwName      = _dr["DWMC"].ToString();
                _su.UserID      = _dr["YHID"].ToString();
                _su.UserName    = _dr["XM"].ToString();
                _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString());
                _su.QxszJB      = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。

                //取岗位信息
                _su.Posts = C_GetGWInfo.Get_PostsByYHID(_su.UserID);
                foreach (SinoPost _sp in _su.Posts)
                {
                    _sp.Rights = C_GetGWInfo.GetRightsOfPost(_sp.PostID, "");
                    if (_sp.IsDefaultPost)
                    {
                        _su.DefaultPost = _sp;
                    }
                }
                if (_su.DefaultPost == null)
                {
                    if (_su.Posts.Count > 0)
                    {
                        _su.DefaultPost = (SinoPost)_su.Posts[0];
                    }
                    else
                    {
                        _su.DefaultPost = new SinoPost();
                    }
                }
                _su.CurrentPost = _su.DefaultPost;
                cn.Close();
            }
            return(_su);
        }