验证中...
Languages: C#
Categories: 数据库相关
Latest update 2019-06-12 21:25
修改密码(更新).txt
Raw Copy
using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
namespace Nurse_Station
{
public partial class 修改密码 : System.Windows.Forms.Form
{
public 修改密码()
{
InitializeComponent();
}
private void btnOk_Click(object sender, EventArgs e)
{
if (txb_Name.Text == "" || txb_OldPwd.Text == "" || txb_NewPwd.Text == "" || txb_NewPwdConfirm.Text == "")
{
MessageBox.Show("信息不完整,请确认完整后再提交!");
return;
}
SqlConnection conn = new SqlConnection();
string sql = string.Format("select UserPwd from Nurse where Name='" + txb_Name.Text + "'");
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
if (txb_OldPwd.Text == sdr.GetString(0).Trim())
{
MessageBox.Show("两次输入的新密码不一样,请重新输入");
txb_NewPwd.Text = "";
txb_NewPwdConfirm.Text = "";
return;
}
else
{
sdr.Close();
string sqlupdate = string.Format("update Nurse set UserPwd='{0}' where UserName='{1}'", txb_NewPwd.Text, txb_Name.Text);
SqlCommand cmdup = new SqlCommand(sqlupdate, conn);
if (cmdup.ExecuteNonQuery() == 0)
{
MessageBox.Show("未知异常");
return;
}
else
{
MessageBox.Show("密码修改成功");
}
}
}
else
{
MessageBox.Show("旧密码错误,或者不能为空");
txb_OldPwd.Text = "";
txb_NewPwd.Text = "";
txb_NewPwdConfirm.Text = "";
return;
}
}
private void button1_Click(object sender, EventArgs e)
{
用户登录 Form = new 用户登录();
Form.Show();
this.Hide();
}
private void button2_Click(object sender, EventArgs e)
{
首页 Form = new 首页();
Form.Show();
this.Hide();
}
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_you_jiang_zheng_wen Zheng_wen_close