Ejemplo n.º 1
0
        private void picLogin_Click(object sender, EventArgs e)
        {
            SqlDataReader sdr = null;

            if (String.IsNullOrEmpty(txtCode.Text.Trim()))
            {
                MessageBox.Show("登录用户不许为空!", "软件提示");
                txtCode.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtPwd.Text))
            {
                MessageBox.Show("登录密码不许为空!", "软件提示");
                txtPwd.Focus();
                return;
            }
            //用户编码不重复
            string strSql = "select * from tb_Operator where OperatorCode = '" + txtCode.Text.Trim() + "'";

            try
            {
                sdr = dataOper.GetDataReader(strSql);
                if (!sdr.HasRows)  //若该用户编码无数据记录
                {
                    MessageBox.Show("登录用户不正确!", "软件提示");
                    txtCode.Focus();
                }
                else
                {
                    sdr.Read();                                                                  //读取唯一的一行记录
                    if (!(MD5Encrypt.GetMD5Password(txtPwd.Text) == sdr["Password"].ToString())) //若密码不相同
                    {
                        MessageBox.Show("登录密码不正确!", "软件提示");
                        txtPwd.Focus();
                    }
                    else
                    {
                        GlobalProperty.OperatorCode = sdr["OperatorCode"].ToString();
                        GlobalProperty.OperatorName = sdr["OperatorName"].ToString();
                        GlobalProperty.Password     = sdr["Password"].ToString();
                        GlobalProperty.IsFlag       = sdr["IsFlag"].ToString();
                        this.Hide();
                        AppForm formApp = new AppForm();
                        formApp.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软件提示");
            }
            finally
            {
                sdr.Close();
            }
        }
Ejemplo n.º 2
0
 //执行修改密码操作
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         MessageBox.Show("密码不能位空");
     }
     else
     {
         if (textBox2.Text == "" || textBox2.Text != textBox1.Text)
         {
             MessageBox.Show("两次密码不一致");
         }
         else
         {
             connclass.getCmd("update tb_Admin set [AdminUserPwd]='" + MD5Encrypt.GetMD5Password(textBox1.Text) + "' where AdminUserName='******'");
             if (MessageBox.Show("密码修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.OK)
             {
                 this.Close();
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txtOperatorName.Text.Trim()))
     {
         MessageBox.Show("操作名称不许为空!", "软件提示");
         txtOperatorName.Focus();
         return;
     }
     if (String.IsNullOrEmpty(txtPassword.Text))
     {
         MessageBox.Show("操作密码不许为空!", "软件提示");
         txtPassword.Focus();
         return;
     }
     if (!(txtPassword.Text == txtAffirmPassword.Text))
     {
         MessageBox.Show("确认密码与操作密码不相同!", "软件提示");
         txtAffirmPassword.Focus();
         return;
     }
     if (this.Tag.ToString() == "Add")
     {
         DataGridViewRow dgvr = cc.AddDataGridViewRow(formOperator.dgvOperator, formOperator.bsOperator);
         dgvr.Cells["OperatorCode"].Value = txtOperatorCode.Text;
         dgvr.Cells["OperatorName"].Value = txtOperatorName.Text.Trim();
         dgvr.Cells["Password"].Value     = MD5Encrypt.GetMD5Password(txtPassword.Text);
         dgvr.Cells["IsFlag"].Value       = "0";
         if (cc.Commit(formOperator.dgvOperator, formOperator.bsOperator))
         {
             if (MessageBox.Show("保存成功,是否继续添加?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
             {
                 txtOperatorCode.Text   = cc.BuildCode("tb_Operator", "Where OperatorCode <> 'mr'", "OperatorCode", "", 4);
                 txtOperatorName.Text   = "";
                 txtPassword.Text       = "";
                 txtAffirmPassword.Text = "";
             }
             else
             {
                 this.Close();
             }
         }
         else
         {
             MessageBox.Show("保存失败!", "软件提示");
         }
     }
     if (this.Tag.ToString() == "Edit")
     {
         DataGridViewRow dgvr = formOperator.dgvOperator.CurrentRow;
         dgvr.Cells["OperatorName"].Value = txtOperatorName.Text.Trim();
         if (cc.Commit(formOperator.dgvOperator, formOperator.bsOperator))
         {
             MessageBox.Show("保存成功!", "软件提示");
             this.Close();
         }
         else
         {
             MessageBox.Show("保存失败!", "软件提示");
         }
     }
 }
Ejemplo n.º 4
0
 //指定用户登录操作
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtLoginName.Text == "")
         {
             MessageBox.Show("用户名不能为空");
         }
         else
         {
             if (txtLoginPwd.Text == "")
             {
                 MessageBox.Show("密码不能为空");
             }
             else
             {
                 OleDbConnection conn = BaseClass.ConnClass.DataConn();
                 conn.Open();
                 OleDbCommand cmd = new OleDbCommand("select count(*) from tb_Admin where AdminUserName='******' and AdminUserPwd='" + MD5Encrypt.GetMD5Password(txtLoginPwd.Text) + "'", conn);
                 int          i   = Convert.ToInt32(cmd.ExecuteScalar());
                 if (i > 0)
                 {
                     frmMain main = new frmMain();
                     frmMain.adminname = txtLoginName.Text; //记录当前登录
                     main.admintime    = DateTime.Now.ToShortDateString();
                     main.Show();                           //显示主窗体
                     this.Hide();
                 }
                 else
                 {
                     MessageBox.Show("用户名或者密码错误");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            errAffirmPassword.Clear();
            errOldPassword.Clear();
            errPassword.Clear();
            if (String.IsNullOrEmpty(txtOldPassword.Text))
            {
                try
                {
                    errOldPassword.SetError(txtOldPassword, "原密码不能为空!");
                    txtOldPassword.Focus();
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                }
            }
            else
            {
                if (!(MD5Encrypt.GetMD5Password(txtOldPassword.Text) == GlobalProperty.Password))
                {
                    try
                    {
                        errOldPassword.SetError(txtOldPassword, "原密码不正确!");
                        txtOldPassword.Focus();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "软件提示");
                    }
                }
            }
            if (String.IsNullOrEmpty(txtPassword.Text))
            {
                try
                {
                    errPassword.SetError(txtPassword, "新密码不能为空!");
                    txtPassword.Focus();
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                }
            }
            if (!(txtAffirmPassWord.Text == txtPassword.Text))
            {
                try
                {
                    errAffirmPassword.SetError(txtAffirmPassWord, "确认密码与新密码不相同!");
                    txtAffirmPassWord.Focus();
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                }
            }
            string strSql = "Update tb_Operator Set Password = '******' Where OperatorCode = '" + GlobalProperty.OperatorCode + "'";

            try
            {
                if (new DataOperate().ExecDataBySql(strSql) > 0)
                {
                    MessageBox.Show("密码修改成功!", "软体提示");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("密码修改失败!", "软体提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软体提示");
            }
        }