Ejemplo n.º 1
0
        public bool Add(out string message)
        {
            try
            {
                if (UserInfoDA.FindAll(string.Format("where [LoginName]='{0}'", LoginName)).Count > 0)
                {
                    message = "登陆帐号已经存在!";
                    return(false);
                }

                m_UserInfoDA.Edition = CurrentUser.Instance.User.Edition;
                m_UserInfoDA.Insert();
                m_UserInfoDA.Save();

                message = "添加用户成功!";

                return(true);
            }
            catch (Exception exception)
            {
                Loger.Instance.WriteErrorLog(exception.Message);
                message = "添加用户失败!";
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static List <UserInfo> GetList(string where)
        {
            List <UserInfo> userInfoList = new List <UserInfo>();

            foreach (UserInfoDA userDA in UserInfoDA.FindAll(where))
            {
                UserInfo userInfo = new UserInfo(userDA);

                userInfoList.Add(userInfo);
            }

            userInfoList.Sort();

            return(userInfoList);
        }
Ejemplo n.º 3
0
        public string Login(string loginName, string password)
        {
            string message = string.Empty;

            try
            {
                m_UserInfoDA = UserInfoDA.Get(string.Format("where [LoginName]='{0}'", loginName));

                if (m_UserInfoDA == null)
                {
                    message = "登陆帐号不存在!";
                }

                if (string.IsNullOrEmpty(message) && !Password.Equals(password))
                {
                    message = "登陆密码不正确!";
                }

                if (string.IsNullOrEmpty(message) && Role == 0)
                {
                    message = "用户没有权限,使用本系统!";
                }

                if (string.IsNullOrEmpty(message))
                {
                    CurrentUser.Instance.User = this;
                    CurrentUser.Instance.Role = new Role();
                    CurrentUser.Instance.Role.Retrieve(Role);
                    CurrentUser.Instance.Modules = CurrentUser.Instance.Role.Modules;
                    CurrentUser.Instance.Edition = new Edition();
                    CurrentUser.Instance.Edition.Retrieve(Edition);
                }
            }
            catch (Exception e)
            {
                message  = e.Message.ToString();
                message += "请与管理员联系!非正常错误!";
            }

            return(message);
        }
Ejemplo n.º 4
0
        public bool Add()
        {
            try
            {
                //版本
                m_EditionDA.Insert();
                m_EditionDA.Save();

                //版本功能
                m_EditionDA.ID = m_EditionDA.GetInsertID();
                InsertEditionModule();

                //角色
                Role role = new Role();
                role.Name      = "系统管理员角色";
                role.IsDefault = true;
                role.Modules   = Modules;
                role.Add(ID);

                //用户
                UserInfoDA userInfo = new UserInfoDA();
                userInfo.UserName    = "******";
                userInfo.LoginName   = string.Format("admin_{0}_{1}", ID, role.ID);
                userInfo.Password    = "******";
                userInfo.Role        = role.ID;
                userInfo.Edition     = ID;
                userInfo.IsDefault   = true;
                userInfo.Description = Name;
                userInfo.Insert();
                userInfo.Save();

                return(true);
            }
            catch (Exception exception)
            {
                Loger.Instance.WriteErrorLog(exception.Message);
                return(false);
            }
        }
Ejemplo n.º 5
0
        public bool Delete()
        {
            try
            {
                ClearRoleModule();

                foreach (UserInfoDA user in UserInfoDA.FindAll(string.Format("where [Role]={0}", ID)))
                {
                    user.Role = 0;
                    user.Update();
                    user.Save();
                }

                m_RoleDA.Delete();
                m_RoleDA.Save();
                return(true);
            }
            catch (Exception exception)
            {
                Loger.Instance.WriteErrorLog(exception.Message);
                return(false);
            }
        }
Ejemplo n.º 6
0
 private UserInfo(UserInfoDA userInfoDA)
 {
     this.m_UserInfoDA = userInfoDA;
 }
Ejemplo n.º 7
0
 public UserInfo()
 {
     m_UserInfoDA = new UserInfoDA();
 }
Ejemplo n.º 8
0
 public void Retrieve(string where)
 {
     m_UserInfoDA = UserInfoDA.Get(where);
 }
Ejemplo n.º 9
0
 public void Retrieve(int id)
 {
     m_UserInfoDA = UserInfoDA.Get(id);
 }