📄 密码修改.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 学生管理系统
{
public partial class 密码修改 : Form
{
private string connectionString = "workstation id=localhost;Integrated Security=SSPI;database=student";
//与数据库的连接
private SqlConnection myConnection;
private SqlCommand cmd;
private Label label1;
private Label label2;
private TextBox textBox1;
private Label label3;
private TextBox textBox3;
private Button button1;
private TextBox textBox2;
public 密码修改()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(28, 52);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 0;
this.label1.Text = "账号";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(28, 104);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 1;
this.label2.Text = "原始密码";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(90, 43);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(138, 21);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(90, 95);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(138, 21);
this.textBox2.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(28, 144);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 12);
this.label3.TabIndex = 4;
this.label3.Text = "新密码";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(90, 135);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(138, 21);
this.textBox3.TabIndex = 5;
//
// button1
//
this.button1.Location = new System.Drawing.Point(119, 199);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "确定";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// 密码修改
//
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "密码修改";
this.ResumeLayout(false);
this.PerformLayout();
}
private void button1_Click(object sender, EventArgs e)
{
myConnection = new SqlConnection(connectionString);
cmd = new SqlCommand("chpassword");
textBox1.Text.ToString().Trim();
cmd.Parameters.Add("@账号", SqlDbType.VarChar).Value = textBox1.Text.ToString().Trim();//你需要的值
cmd.Parameters.Add("@旧密码", SqlDbType.VarChar).Value = textBox2.Text.ToString().Trim();//你需要的值
cmd.Parameters.Add("@新密码", SqlDbType.VarChar).Value = textBox3.Text.ToString().Trim();//你需要的值
cmd.Connection = myConnection;
cmd.Parameters.Add("@bool", SqlDbType.Int).Direction=ParameterDirection.Output;
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter Adapte = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
Adapte.Fill(ds);
string output = cmd.Parameters["@bool"].Value.ToString();
if (Convert.ToInt32(output) == 1)
{
MessageBox.Show("修改成功!");
Dispose(true);
}
else
{
MessageBox.Show("修改失败!");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -