コード例 #1
0
ファイル: ChangePwd.cs プロジェクト: uwitec/Wms-7
 private void btnConfirmClick(object sender, EventArgs e)
 {
     BLL.tb_user   dal   = new BLL.tb_user();
     Model.tb_user model = new Model.tb_user();
     if (this.txtpwd.Text.Trim() == "")
     {
         MessageBox.Show("请输入旧密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         this.txtpwd.Focus();
         return;
     }
     if (this.txtpassword.Text.Trim() == "")
     {
         MessageBox.Show("请输入新密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         this.txtpassword.Focus();
         return;
     }
     if (this.txtpasswordok.Text.Trim() == "")
     {
         MessageBox.Show("请再次输入新密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         this.txtpasswordok.Focus();
         return;
     }
     if (!String.IsNullOrEmpty(m_id))
     {
         DataRow[] dr = dal.GetList(" ").Tables[0].Select(" u_id=" + m_id);
         if (dr.Length > 0)
         {
             if (dr[0]["u_pwd"].ToString() != txtpwd.Text.Trim().ToString())
             {
                 MessageBox.Show("旧密码错误", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 this.txtpwd.Focus();
                 this.txtpwd.Text        = "";
                 this.txtpassword.Text   = "";
                 this.txtpasswordok.Text = "";
             }
             else
             {
                 if (this.txtpassword.Text != this.txtpasswordok.Text)
                 {
                     MessageBox.Show("两次新密码不一致", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 }
                 else
                 {
                     model       = dal.GetModel(int.Parse(m_id));
                     model.u_pwd = this.txtpasswordok.Text;
                     dal.Update(model);
                     // DialogResult result= MessageBox.Show("","",MessageBo)
                     MessageBox.Show("修改密码成功", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.txtpwd.Text        = "";
                     this.txtpassword.Text   = "";
                     this.txtpasswordok.Text = "";
                     this.Close();
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: AccountManage.cs プロジェクト: uwitec/Wms-7
 private void dgvCellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     optrowid = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
     if (!String.IsNullOrEmpty(optrowid))
     {
         model = dal.GetModel(Int32.Parse(optrowid));
         if (model != null)
         {
             txtname.Text    = model.u_name;
             txtlogname.Text = model.u_log;
             txttel.Text     = model.u_tel;
             txtemail.Text   = model.u_email;
         }
     }
 }
コード例 #3
0
ファイル: AccountManage.cs プロジェクト: uwitec/Wms-7
        private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.ToolTipText == "新增")
            {
                rstValue();
                setModifyMode(true);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "修改")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    setModifyMode(true);
                }
                else
                {
                    MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "删除")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    DialogResult result = MessageBox.Show("确认删除?", "删除数据", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        dal.Delete(int.Parse(optrowid));
                        rstValue();
                        MessageBox.Show("恭喜你,删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        bindData(" u_type=1 ");
                        setModifyMode(false);
                        optrowid = null;
                    }
                }
                else
                {
                    MessageBox.Show("请选择所要删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "提交")
            {
                if (validateInput())
                {
                    model = new Model.tb_user();
                    if (!String.IsNullOrEmpty(optrowid))
                    {
                        model = dal.GetModel(int.Parse(optrowid));
                    }
                    model.u_name  = this.txtname.Text;
                    model.u_log   = this.txtlogname.Text;
                    model.u_tel   = this.txttel.Text;
                    model.u_email = this.txtemail.Text;
                    if (String.IsNullOrEmpty(optrowid))
                    {
                        model.u_type    = 1;
                        model.u_adddate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        model.u_pwd     = "000000";
                        int i = dal.Add(model);
                        if (i > 0)
                        {
                            MessageBox.Show("恭喜你,新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData(" u_type=1 ");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                    else
                    {
                        if (dal.Update(model))
                        {
                            MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData(" u_type=1 ");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                }
            }

            if (e.Button.ToolTipText == "取消")
            {
                bindData(" u_type=1 ");
                rstValue();
                setModifyMode(false);
                optrowid = null;
            }

            if (e.Button.ToolTipText == "退出")
            {
                this.Close();
            }
        }
コード例 #4
0
ファイル: Login.cs プロジェクト: uwitec/Wms-7
        private void btnConfirmClick(object sender, EventArgs e)
        {
            //string pgname = txtUser.Text.ToString().Trim();
            //string pgpwd = txtPwd.Text.ToString().Trim();

            string pgname = "admin";
            string pgpwd  = "admin";

            if (pgname == "" || pgpwd == "")
            {
                MessageBox.Show("用户名或密码不能为空");
                txtUser.Focus();
                return;
            }
            user = dal.GetModel(pgname, pgpwd);
            if (user != null)
            {
                switch (user.u_type)
                {
                case 0:
                    if (cbAccountType.Text != "管理员")
                    {
                        MessageBox.Show("登录权限错误");
                    }
                    else
                    {
                        Views.Main f5 = new Views.Main();
                        f5.m_username = user.u_name;
                        f5.m_id       = user.u_id.ToString();
                        f5.m_ty       = user.u_type.ToString();
                        f5.Show();
                        this.Hide();
                    }
                    break;

                case 1:
                    if (cbAccountType.Text != "普通用户")
                    {
                        MessageBox.Show("登录权限错误");
                    }
                    else
                    {
                        Views.Main main = new Views.Main();
                        main.m_username = user.u_name;
                        main.m_id       = user.u_id.ToString();
                        main.m_ty       = user.u_type.ToString();
                        main.Show();
                        this.Hide();
                    }
                    break;

                default:
                    MessageBox.Show("数据错误");
                    break;
                }
            }
            else
            {
                MessageBox.Show("用户名或密码不正确");
                return;
            }
        }
コード例 #5
0
ファイル: tb_user.cs プロジェクト: uwitec/Wms-7
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.tb_user model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.u_log != null)
            {
                strSql1.Append("u_log,");
                strSql2.Append("'" + model.u_log + "',");
            }
            if (model.u_pwd != null)
            {
                strSql1.Append("u_pwd,");
                strSql2.Append("'" + model.u_pwd + "',");
            }
            if (model.u_no != null)
            {
                strSql1.Append("u_no,");
                strSql2.Append("'" + model.u_no + "',");
            }
            if (model.u_name != null)
            {
                strSql1.Append("u_name,");
                strSql2.Append("'" + model.u_name + "',");
            }
            if (model.u_tel != null)
            {
                strSql1.Append("u_tel,");
                strSql2.Append("'" + model.u_tel + "',");
            }
            if (model.u_email != null)
            {
                strSql1.Append("u_email,");
                strSql2.Append("'" + model.u_email + "',");
            }
            if (model.u_type != null)
            {
                strSql1.Append("u_type,");
                strSql2.Append("" + model.u_type + ",");
            }
            if (model.u_sex != null)
            {
                strSql1.Append("u_sex,");
                strSql2.Append("'" + model.u_sex + "',");
            }
            if (model.u_address != null)
            {
                strSql1.Append("u_address,");
                strSql2.Append("'" + model.u_address + "',");
            }
            if (model.u_adddate != null)
            {
                strSql1.Append("u_adddate,");
                strSql2.Append("'" + model.u_adddate + "',");
            }
            strSql.Append("insert into tb_user(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #6
0
ファイル: tb_user.cs プロジェクト: uwitec/Wms-7
        public Model.tb_user GetModel(string log, string pwd)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" u_id,u_log,u_pwd,u_no,u_name,u_tel,u_email,u_type,u_sex,u_address,u_adddate ");
            strSql.Append(" from tb_user ");
            strSql.Append(" where u_log='" + log + "' and u_pwd='" + pwd + "' ");
            Model.tb_user model = new Model.tb_user();
            DataSet       ds    = DbSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["u_id"] != null && ds.Tables[0].Rows[0]["u_id"].ToString() != "")
                {
                    model.u_id = int.Parse(ds.Tables[0].Rows[0]["u_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["u_log"] != null && ds.Tables[0].Rows[0]["u_log"].ToString() != "")
                {
                    model.u_log = ds.Tables[0].Rows[0]["u_log"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_pwd"] != null && ds.Tables[0].Rows[0]["u_pwd"].ToString() != "")
                {
                    model.u_pwd = ds.Tables[0].Rows[0]["u_pwd"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_no"] != null && ds.Tables[0].Rows[0]["u_no"].ToString() != "")
                {
                    model.u_no = ds.Tables[0].Rows[0]["u_no"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_name"] != null && ds.Tables[0].Rows[0]["u_name"].ToString() != "")
                {
                    model.u_name = ds.Tables[0].Rows[0]["u_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_tel"] != null && ds.Tables[0].Rows[0]["u_tel"].ToString() != "")
                {
                    model.u_tel = ds.Tables[0].Rows[0]["u_tel"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_email"] != null && ds.Tables[0].Rows[0]["u_email"].ToString() != "")
                {
                    model.u_email = ds.Tables[0].Rows[0]["u_email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_type"] != null && ds.Tables[0].Rows[0]["u_type"].ToString() != "")
                {
                    model.u_type = int.Parse(ds.Tables[0].Rows[0]["u_type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["u_sex"] != null && ds.Tables[0].Rows[0]["u_sex"].ToString() != "")
                {
                    model.u_sex = ds.Tables[0].Rows[0]["u_sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_address"] != null && ds.Tables[0].Rows[0]["u_address"].ToString() != "")
                {
                    model.u_address = ds.Tables[0].Rows[0]["u_address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["u_adddate"] != null && ds.Tables[0].Rows[0]["u_adddate"].ToString() != "")
                {
                    model.u_adddate = ds.Tables[0].Rows[0]["u_adddate"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
ファイル: tb_user.cs プロジェクト: uwitec/Wms-7
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.tb_user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_user set ");
            if (model.u_log != null)
            {
                strSql.Append("u_log='" + model.u_log + "',");
            }
            else
            {
                strSql.Append("u_log= null ,");
            }
            if (model.u_pwd != null)
            {
                strSql.Append("u_pwd='" + model.u_pwd + "',");
            }
            else
            {
                strSql.Append("u_pwd= null ,");
            }
            if (model.u_no != null)
            {
                strSql.Append("u_no='" + model.u_no + "',");
            }
            else
            {
                strSql.Append("u_no= null ,");
            }
            if (model.u_name != null)
            {
                strSql.Append("u_name='" + model.u_name + "',");
            }
            else
            {
                strSql.Append("u_name= null ,");
            }
            if (model.u_tel != null)
            {
                strSql.Append("u_tel='" + model.u_tel + "',");
            }
            else
            {
                strSql.Append("u_tel= null ,");
            }
            if (model.u_email != null)
            {
                strSql.Append("u_email='" + model.u_email + "',");
            }
            else
            {
                strSql.Append("u_email= null ,");
            }
            if (model.u_type != null)
            {
                strSql.Append("u_type=" + model.u_type + ",");
            }
            else
            {
                strSql.Append("u_type= null ,");
            }
            if (model.u_sex != null)
            {
                strSql.Append("u_sex='" + model.u_sex + "',");
            }
            else
            {
                strSql.Append("u_sex= null ,");
            }
            if (model.u_address != null)
            {
                strSql.Append("u_address='" + model.u_address + "',");
            }
            else
            {
                strSql.Append("u_address= null ,");
            }
            if (model.u_adddate != null)
            {
                strSql.Append("u_adddate='" + model.u_adddate + "',");
            }
            else
            {
                strSql.Append("u_adddate= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where u_id=" + model.u_id + "");
            int rowsAffected = DbSQL.ExecuteSql(strSql.ToString());

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