Пример #1
0
        //管理员创建用户
        public int registUser(UserBean bean)
        {

            try
            {
                string selectSql = "select * from users as u where u.ACCOUNT='" + @bean.Account + "'";
                reade = MySqlHelper.ExecuteReader(MySqlHelper.Conn, CommandType.Text,selectSql, new MySqlParameter("@bean.Account", bean.Account));
                if (reade.Read()) return HAS;
                string pawMd = Session.MD5Encrypt(bean.Password);
                string sql = "insert into users(ACCOUNT,USER_NAME,TYPE,PASSWORD,STATUS,CREATE_ID,CREATE_TIME,PHONE) values('" +
                            @bean.Account + "','" + @bean.UserName + "'," + @bean.Type + ",'" + @pawMd + "'," + @bean.Status + "," +
                            @bean.CreateId + ",'" + @bean.CreateTime + "','"[email protected]+"')";
                MySqlParameter[] parameter = 
            {
                new MySqlParameter("@bean.Account",bean.Account),
                new MySqlParameter("@bean.UserName",bean.UserName),
                new MySqlParameter("@bean.Type",bean.Type),
                new MySqlParameter("@pawMd",pawMd),
                new MySqlParameter("@bean.Status",bean.Status),
                new MySqlParameter("@bean.CreateId",bean.CreateId),
                new MySqlParameter("@bean.CreateTime",bean.CreateTime.ToString("yyyy-MM-dd hh:mm:ss")),
                 new MySqlParameter("@bean.Phone",bean.Phone),
            };
                MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text,sql, parameter);
            }
            catch (Exception e)
            {
                e.GetBaseException();
                return SYSTEM_EXCEPTION;
            }
            return SUCCESS;
        }
Пример #2
0
 private void Save_Edit(object sender, RoutedEventArgs e)
 {
     ComboBoxItem status = (ComboBoxItem)this.status.SelectedItem;
     UserBean bean = new UserBean();
     QueryUser query = new QueryUser();
     query.Account = UserManagerBean.AddUser.queryAccount.Text;
     query.UserName = UserManagerBean.AddUser.queryName.Text;
     bean.Id = int.Parse(this.userId.Content.ToString());
     bean.UserName = this.userName.Text;
     bean.Phone = this.userPhone.Text;
     bean.Status = int.Parse(status.Tag.ToString());
     bean.Type = this.userType.SelectedIndex;
     Users user = new Users();
     int state = user.saveUserEdit(bean);
     if (state == BaseRequest.SUCCESS)
     {
         JXMessageBox.Show(Window.GetWindow(this), "编辑用信息保存成功!", MsgImage.Success);
         this.Close();
         UserManagerBean.AddUser.page.ShowPages(UserManagerBean.AddUser.userData, user.getUsersList(query), BaseRequest.PAGE_SIZE);
     }
     else if (state == BaseRequest.SYSTEM_EXCEPTION)
     {
         JXMessageBox.Show(Window.GetWindow(this), "系统异常,请联系管理员!", MsgImage.Error);
     }
     else
     {
         JXMessageBox.Show(Window.GetWindow(this), "未知错误", MsgImage.Error);
     }
 }
Пример #3
0
 //管理员创建用户
 public int registUser(UserBean bean)
 {
     try
     {
         string selectSql = "select * from users as u where u.ACCOUNT='" + @bean.Account + "'";
         reade = MySqlHelper.ExecuteReader(MySqlHelper.Conn, CommandType.Text, selectSql, new MySqlParameter("@bean.Account", bean.Account));
         if (reade.Read())
         {
             return(HAS);
         }
         string pawMd = Session.MD5Encrypt(bean.Password);
         string sql   = "insert into users(ACCOUNT,USER_NAME,TYPE,PASSWORD,STATUS,CREATE_ID,CREATE_TIME,PHONE) values('" +
                        @bean.Account + "','" + @bean.UserName + "'," + @bean.Type + ",'" + @pawMd + "'," + @bean.Status + "," +
                        @bean.CreateId + ",'" + @bean.CreateTime + "','" + @bean.Phone + "')";
         MySqlParameter[] parameter =
         {
             new MySqlParameter("@bean.Account",    bean.Account),
             new MySqlParameter("@bean.UserName",   bean.UserName),
             new MySqlParameter("@bean.Type",       bean.Type),
             new MySqlParameter("@pawMd",           pawMd),
             new MySqlParameter("@bean.Status",     bean.Status),
             new MySqlParameter("@bean.CreateId",   bean.CreateId),
             new MySqlParameter("@bean.CreateTime", bean.CreateTime.ToString("yyyy-MM-dd hh:mm:ss")),
             new MySqlParameter("@bean.Phone",      bean.Phone),
         };
         MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sql, parameter);
     }
     catch (Exception e)
     {
         e.GetBaseException();
         return(SYSTEM_EXCEPTION);
     }
     return(SUCCESS);
 }
Пример #4
0
 public int saveUserEdit(UserBean bean)
 {
     try
     {
         string date = Convert.ToDateTime(DateTime.Now).ToString(BaseRequest.DATE_TIME_FORMAT);
         string sql  = "UPDATE users AS u SET u.USER_NAME='" + @bean.UserName + "',u.TYPE=" + @bean.Type + ",u.PHONE='" +
                       @bean.Phone + "', STATUS=" + @bean.Status + ",UPDATE_USER_ID=" + @Session.UserId + ",UPDATE_TIME='" + @date + "' where u.ID=" + @bean.Id;
         MySqlParameter[] parameters =
         {
             new MySqlParameter("@bean.UserName",  bean.UserName),
             new MySqlParameter("@bean.Type",      bean.Type),
             new MySqlParameter("@bean.Phone",     bean.Phone),
             new MySqlParameter("@bean.Status",    bean.Status),
             new MySqlParameter("@Session.UserId", Session.UserId),
             new MySqlParameter("@date",           date),
             new MySqlParameter("@bean.Id",        bean.Id),
         };
         MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sql, parameters);
         return(SUCCESS);
     }catch (Exception e)
     {
         e.GetBaseException();
         return(SYSTEM_EXCEPTION);
     }
 }
Пример #5
0
        private void Submit_AddUser(object sender, RoutedEventArgs e)
        {
            if (ValidateUtil.CheckFolderName(this.account.Text) == false)
            {
                JXMessageBox.Show(Window.GetWindow(this), "请填写帐号!", MsgImage.Error);
                return;
            }
            if (ValidateUtil.CheckFolderName(this.userName.Text) == false)
            {
                JXMessageBox.Show(Window.GetWindow(this), "请填写用户姓名!", MsgImage.Error);
                return;
            }
            if (ValidateUtil.CheckPasswordStrength(this.password.Password) == false)
            {
                JXMessageBox.Show(Window.GetWindow(this), "请输入6位以上的密码长度!", MsgImage.Error);
                return;
            }

            if (!this.password.Password.Equals(this.password2.Password))
            {
                JXMessageBox.Show(Window.GetWindow(this), "输入密码不一致,请重新输入!", MsgImage.Error);
                return;
            }
            Users u = new Users();
            UserBean bean = new UserBean();
            QueryUser query = new QueryUser();
            query.Account = UserManagerBean.AddUser.queryAccount.Text;
            query.UserName = UserManagerBean.AddUser.queryName.Text;
            bean.Account = this.account.Text;
            bean.UserName = this.userName.Text;
            bean.Password = this.password.Password;
            bean.Status = 0;
            bean.CreateId = Session.UserId;
            bean.CreateTime = Convert.ToDateTime(DateTime.Now);
            bean.Phone = this.phone.Text;
            ComboBoxItem type = (ComboBoxItem)this.userType.SelectedItem;
            bean.Type = int.Parse(type.Tag.ToString());
            int state = u.registUser(bean);
            Window targe = Window.GetWindow(this);
            if (state == BaseRequest.HAS)
            {
                JXMessageBox.Show(Window.GetWindow(this), "该账号已被使用!", MsgImage.Error);
            }
            else if (state==BaseRequest.SUCCESS)
            {
                JXMessageBox.Show(Window.GetWindow(this), "新增用户成功!", MsgImage.Error);
                UserManagerBean.AddUser.page.ShowPages(UserManagerBean.AddUser.userData, u.getUsersList(query), BaseRequest.PAGE_SIZE);
                this.Close();
            }
            else
            {
                JXMessageBox.Show(Window.GetWindow(this), "系统异常,请联系管理员!", MsgImage.Error);
            }
        }
Пример #6
0
 public int saveUserEdit(UserBean bean)
 {
     try
     {
         string date = Convert.ToDateTime(DateTime.Now).ToString(BaseRequest.DATE_TIME_FORMAT);
         string sql = "UPDATE users AS u SET u.USER_NAME='" + @bean.UserName + "',u.TYPE=" + @bean.Type + ",u.PHONE='" +
             @bean.Phone + "', STATUS=" + @bean.Status+ ",UPDATE_USER_ID=" + @Session.UserId + ",UPDATE_TIME='" + @date + "' where u.ID=" + @bean.Id;
         MySqlParameter[] parameters ={
                                          new MySqlParameter("@bean.UserName",bean.UserName),
                                          new MySqlParameter("@bean.Type",bean.Type),
                                          new MySqlParameter("@bean.Phone",bean.Phone),
                                          new MySqlParameter("@bean.Status",bean.Status),
                                          new MySqlParameter("@Session.UserId",Session.UserId),
                                          new MySqlParameter("@date",date),
                                          new MySqlParameter("@bean.Id",bean.Id),
                                     };
         MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sql, parameters);
         return SUCCESS;
     }catch(Exception e)
     {
         e.GetBaseException();
         return SYSTEM_EXCEPTION;
     }
 }