Example #1
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        public void GetUserInfo()
        {
            BU_UserInfo bll  = new BU_UserInfo();
            MU_UserInfo user = bll.GetModel(id);

            U_Name.Text     = user.U_Name;    //用户名
            U_Name.ReadOnly = true;
            U_RelName.Text  = user.U_RelName; //用户真实姓名
            if (user.U_Sex == true)           //女
            {
                this.radio_women.Checked = true;
            }
            this.U_Birthday.Value        = user.U_Birthday;           //出生日期
            U_IdCard.Text                = user.U_IdCard;             //身份证号
            U_Position.Text              = user.U_NativePlace;        //籍贯
            U_NativePlace.Text           = user.U_Position;           //籍贯
            U_Address.Text               = user.U_Address;            //家庭住址
            U_Telephone.Text             = user.U_Telephone;          //电话号码
            U_Email.Text                 = user.U_Email;              //邮箱号码
            U_PostalId.Text              = user.U_DepType.ToString(); //user.U_PostalId;//邮编号码
            textBox1.Text                = user.U_QQ;                 //QQ
            this.comboBox1.SelectedValue = user.U_DepType.ToString();
            //显示用户生活照
            if (user.U_Image != null)
            {
                byte_Image2 = (byte[])(user.U_Image);
                MemoryStream ms = new MemoryStream(byte_Image2);
                pictureBox1.Image = Image.FromStream(ms);
            }
        }
Example #2
0
 private void login_Load(object sender, EventArgs e)
 {
     if (Pagetype == "update")
     {
         DAL.DU_UserInfo du  = new DAL.DU_UserInfo();
         MU_UserInfo     use = du.GetModel(Uid);
         this.txt_username.Text = use.U_Name;
         this.textBox_Name.Text = use.U_RelName;
         if (use.U_Sex)
         {
             this.radio_women.Checked = true;
         }
         else
         {
             this.radion_man.Checked = true;
         }
         this.textBox_Tel.Text      = use.U_Telephone;
         this.label2.Visible        = false;
         this.txt_pwd.Visible       = false;
         this.label3.Visible        = false;
         this.txt_pwd2.Visible      = false;
         this.button1.Visible       = false;
         this.txt_username.ReadOnly = true;
     }
     else
     {
         this.button3.Visible = false;
     }
 }
Example #3
0
        public bool Update(MU_UserInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update U_UserInfo set ");
            strSql.Append(" U_Telephone = @U_Telephone , ");
            strSql.Append(" U_Name2 = @U_QQ , ");
            strSql.Append(" U_RelName = @U_RelName , ");
            strSql.Append(" U_Sex = @U_Sex  ");
            strSql.Append(" where U_Id=@U_Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@U_Id",        SqlDbType.Int,      4),
                new SqlParameter("@U_Telephone", SqlDbType.VarChar, 50),
                new SqlParameter("@U_RelName",   SqlDbType.VarChar, 50),
                new SqlParameter("@U_Sex",       SqlDbType.Bit,      1),
                new SqlParameter("@U_QQ",        SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.U_Id;
            parameters[1].Value = model.U_Telephone;
            parameters[2].Value = model.U_RelName;
            parameters[3].Value = model.U_Sex;
            parameters[4].Value = model.U_Name;

            foreach (SqlParameter p in parameters)   //没有对传入的数据作空值的处理
            {
                if (p.Value == null)
                {
                    p.Value = DBNull.Value;
                }
            }

            int rows = DBHelp.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MU_UserInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into U_UserInfo(");
            strSql.Append("U_LoginTime,U_RelName,U_Name2,U_Sex,U_PassWord,U_Telephone");
            strSql.Append(") values (");
            strSql.Append("@U_LoginTime,@U_RoleType,@U_Name,@U_Sex,@U_PassWord,@U_Birthday");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@U_LoginTime", SqlDbType.DateTime),
                new SqlParameter("@U_RoleType",  SqlDbType.VarChar,   50),
                new SqlParameter("@U_Name",      SqlDbType.VarChar,   50),
                new SqlParameter("@U_Sex",       SqlDbType.Bit,        1),
                new SqlParameter("@U_PassWord",  SqlDbType.VarChar,   50),
                new SqlParameter("@U_Birthday",  SqlDbType.VarChar, 50)
            };

            parameters[0].Value = model.U_LoginTime;
            parameters[1].Value = model.U_RelName;
            parameters[2].Value = model.U_Name;
            parameters[3].Value = model.U_Sex;
            parameters[4].Value = model.U_PassWord;
            parameters[5].Value = model.U_Telephone;

            object obj = DBHelp.ExecuteNonQuery(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            string UserName = this.txt_username.Text.Trim(); //姓名
            string UName    = this.textBox_Name.Text.Trim(); //姓名
            bool   Sex      = false;                         //性别

            if (this.radio_women.Checked)
            {
                Sex = true;
            }
            string Tel = this.textBox_Tel.Text;//出身日期

            if (UserName == "")
            {
                MessageBox.Show("用户名输入不能为空,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MU_UserInfo info = new MU_UserInfo();
                info.U_Id        = Uid;
                info.U_Name      = UserName;
                info.U_RelName   = UName;
                info.U_Sex       = Sex;
                info.U_Telephone = Tel;

                DAL.DU_UserInfo du = new DAL.DU_UserInfo();
                if (du.Update(info))
                {
                    MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                this.Close();
            }
        }
Example #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MU_UserInfo model)
 {
     return(UserInfo.Update(model));
 }
Example #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MU_UserInfo model)
 {
     return(UserInfo.Add(model));
 }
Example #8
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string UserName = this.txt_username.Text.Trim(); //姓名

            bool Sex = true;                                 //性别

            if (this.radio_women.Checked)
            {
                Sex = false;
            }

            string birthday = this.time_Birthday.Text;   //出身日期
            string pwd      = this.txt_pwd.Text.Trim();  //密码1
            string pwd2     = this.txt_pwd2.Text.Trim(); //密码2

            if (UserName == "")
            {
                MessageBox.Show("用户名输入不能为空,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (pwd == "")
            {
                MessageBox.Show("密码不能为空,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (pwd2 == "")
            {
                MessageBox.Show("确认密码不能为空,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

            else if (pwd != pwd2)
            {
                MessageBox.Show("密码输入不相同,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.txt_pwd2.Text = "";
            }
            else
            {
                BU_UserInfo Bll = new BU_UserInfo();

                int a = Bll.ExistsName(UserName);

                if (a != 0)
                {
                    MessageBox.Show("用户名已经存在,请重新注册", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MU_UserInfo info = new MU_UserInfo();

                    //密码处理,经过加密
                    byte[] result = Encoding.Default.GetBytes(pwd2);//pwd2为输入密码的文本框
                    MD5    md5    = new MD5CryptoServiceProvider();
                    byte[] output = md5.ComputeHash(result);
                    info.U_PassWord = BitConverter.ToString(output).Replace("-", "");

                    info.U_Name      = UserName;
                    info.U_Sex       = Sex;
                    info.U_Birthday  = Convert.ToDateTime(birthday);
                    info.U_LoginTime = DateTime.Now;
                    if (Pagetype == "AddAdmin")
                    {
                        info.U_RoleType = 2;//管理员
                    }
                    else
                    {
                        info.U_RoleType = 1;//普通用户
                    }


                    int Result = Bll.Add(info);

                    if (Result == 0)
                    {
                        MessageBox.Show("注册失败,请重新注册", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        MessageBox.Show("注册成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    getName(UserName);
                    this.Close();
                }
            }
        }
Example #9
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            MU_UserInfo user = new MU_UserInfo();
            Common      com  = new Common();

            if (byte_Image == null) //显示用户生活照
            {
                if (byte_Image2 == null)
                {
                    user.U_Image = null;
                }
                else
                {
                    user.U_Image = byte_Image2;
                }
            }
            else
            {
                user.U_Image = byte_Image;
            }
            user.U_Name = U_Name.Text;       //用户名

            user.U_RelName = U_RelName.Text; //用户真实姓名

            user.U_Sex = false;

            if (this.radio_women.Checked == true)//男
            {
                user.U_Sex = true;
            }
            user.U_Birthday = this.U_Birthday.Value;//出生日期

            if (U_IdCard.Text != "")
            {
                if (com.RegexcardID(U_IdCard.Text))
                {
                    user.U_IdCard = U_IdCard.Text;//身份证号
                }
                else
                {
                    MessageBox.Show("身份证号格式输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                user.U_IdCard = "";
            }
            user.U_NativePlace = U_Position.Text; //民族

            user.U_Address = U_Address.Text;      //家庭住址

            if (U_Telephone.Text != "")
            {
                if (com.RegexPhone(U_Telephone.Text))
                {
                    user.U_Telephone = U_Telephone.Text;//电话号码
                }
                else
                {
                    MessageBox.Show("电话号码格式输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                user.U_Telephone = "";
            }

            if (U_Email.Text != "")
            {
                if (com.RegexEmail(U_Email.Text))
                {
                    user.U_Email = U_Email.Text;//邮箱号码
                }
                else
                {
                    MessageBox.Show("邮箱号码格式输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                user.U_Email = "";
            }
            user.U_PostalId = U_PostalId.Text; //邮编号码
            user.U_QQ       = textBox1.Text;   //QQ
            user.U_Id       = id;
            bool flag = new BU_UserInfo().Update(user);

            if (flag)
            {
                //if (LoginRoler.U_ROlesType == 2)
                //{
                //getName("随便传的值");
                //}
                MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.Close();
            }
            else
            {
                MessageBox.Show("修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            this.button4.Visible = true;
        }
Example #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MU_UserInfo GetModel(int U_Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append("  from U_UserInfo ");
            strSql.Append(" where U_Id=@U_Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@U_Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = U_Id;

            MU_UserInfo model = new MU_UserInfo();
            DataSet     ds    = DBHelp.DateSet(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["U_Id"].ToString() != "")
                {
                    model.U_Id = int.Parse(ds.Tables[0].Rows[0]["U_Id"].ToString());
                }
                model.U_NativePlace = ds.Tables[0].Rows[0]["U_NativePlace"].ToString();
                model.U_Address     = ds.Tables[0].Rows[0]["U_Address"].ToString();
                model.U_Telephone   = ds.Tables[0].Rows[0]["U_Telephone"].ToString();
                model.U_Email       = ds.Tables[0].Rows[0]["U_Email"].ToString();
                model.U_PostalId    = ds.Tables[0].Rows[0]["U_PostalId"].ToString();
                model.U_Position    = ds.Tables[0].Rows[0]["U_Position"].ToString();
                model.U_Reamrk      = ds.Tables[0].Rows[0]["U_Remark"].ToString();
                if (ds.Tables[0].Rows[0]["U_LoginTime"].ToString() != "")
                {
                    model.U_LoginTime = DateTime.Parse(ds.Tables[0].Rows[0]["U_LoginTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["U_RoleType"].ToString() != "")
                {
                    model.U_RoleType = int.Parse(ds.Tables[0].Rows[0]["U_RoleType"].ToString());
                }
                model.U_Name    = ds.Tables[0].Rows[0]["U_Name2"].ToString();
                model.U_RelName = ds.Tables[0].Rows[0]["U_RelName"].ToString();
                if (ds.Tables[0].Rows[0]["U_Sex"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["U_Sex"].ToString() == "1") || (ds.Tables[0].Rows[0]["U_Sex"].ToString().ToLower() == "true"))
                    {
                        model.U_Sex = true;
                    }
                    else
                    {
                        model.U_Sex = false;
                    }
                }
                model.U_PassWord = ds.Tables[0].Rows[0]["U_PassWord"].ToString();
                if (ds.Tables[0].Rows[0]["U_Birthday"].ToString() != "")
                {
                    model.U_Birthday = DateTime.Parse(ds.Tables[0].Rows[0]["U_Birthday"].ToString());
                }
                if (ds.Tables[0].Rows[0]["U_PsdType"].ToString() != "")
                {
                    model.U_PsdType = int.Parse(ds.Tables[0].Rows[0]["U_PsdType"].ToString());
                }
                model.U_PsdAnswer = ds.Tables[0].Rows[0]["U_PsdAnswer"].ToString();
                model.U_IdCard    = ds.Tables[0].Rows[0]["U_IdCard"].ToString();
                if (ds.Tables[0].Rows[0]["U_Image"].ToString() != "")
                {
                    model.U_Image = (byte[])ds.Tables[0].Rows[0]["U_Image"];
                }
                //model.U_DepType = int.Parse(ds.Tables[0].Rows[0]["U_DepType"].ToString());
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #11
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateAAA(MU_UserInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update U_UserInfo set ");
            strSql.Append(" U_NativePlace = @U_NativePlace , ");
            strSql.Append(" U_Address = @U_Address , ");
            strSql.Append(" U_Telephone = @U_Telephone , ");
            strSql.Append(" U_Email = @U_Email , ");
            strSql.Append(" U_PostalId = @U_PostalId , ");
            strSql.Append(" U_RelName = @U_RelName , ");
            strSql.Append(" U_Sex = @U_Sex , ");
            strSql.Append(" U_Birthday = @U_Birthday , ");
            strSql.Append(" U_IdCard = @U_IdCard,  ");
            strSql.Append(" U_Image = @U_Image ,");
            strSql.Append(" U_QQ = @U_QQ ");
            strSql.Append(" where U_Id=@U_Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@U_Id",          SqlDbType.Int,        4),
                new SqlParameter("@U_NativePlace", SqlDbType.VarChar,   20),
                new SqlParameter("@U_Address",     SqlDbType.VarChar,   50),
                new SqlParameter("@U_Telephone",   SqlDbType.VarChar,   50),
                new SqlParameter("@U_Email",       SqlDbType.VarChar,   50),
                new SqlParameter("@U_PostalId",    SqlDbType.VarChar,   20),
                new SqlParameter("@U_RelName",     SqlDbType.VarChar,   50),
                new SqlParameter("@U_Sex",         SqlDbType.Bit,        1),
                new SqlParameter("@U_Birthday",    SqlDbType.DateTime),
                new SqlParameter("@U_IdCard",      SqlDbType.VarChar,   20),
                new SqlParameter("@U_Image",       SqlDbType.Image),
                new SqlParameter("@U_QQ",          SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.U_Id;
            parameters[1].Value  = model.U_NativePlace;
            parameters[2].Value  = model.U_Address;
            parameters[3].Value  = model.U_Telephone;
            parameters[4].Value  = model.U_Email;
            parameters[5].Value  = model.U_PostalId;
            parameters[6].Value  = model.U_RelName;
            parameters[7].Value  = model.U_Sex;
            parameters[8].Value  = model.U_Birthday;
            parameters[9].Value  = model.U_IdCard;
            parameters[10].Value = model.U_Image;
            parameters[11].Value = model.U_QQ;

            foreach (SqlParameter p in parameters)   //没有对传入的数据作空值的处理
            {
                if (p.Value == null)
                {
                    p.Value = DBNull.Value;
                }
            }

            int rows = DBHelp.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }