Pwd.cs
上传用户:nbcygd
上传日期:2008-07-25
资源大小:2566k
文件大小:2k
源码类别:

SQL Server

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Data.Sql;
  9. using System.Data.SqlClient;
  10. using System.Data.SqlTypes;
  11. namespace Super_market
  12. {
  13.     public partial class Pwd : Form
  14.     {        
  15.         private SqlConnection con;
  16.         private SqlConnectionStringBuilder b = new SqlConnectionStringBuilder();              
  17.         private string s = "";
  18.         public Pwd()
  19.         {
  20.             b.DataSource = ".";
  21.             b.InitialCatalog = "wkdl";
  22.             b.IntegratedSecurity = true;
  23.             con = new SqlConnection(b.ConnectionString);
  24.             InitializeComponent();
  25.             this.skinEngine1.SkinFile = "vista1.ssk";
  26.         }
  27.         public Pwd(string str)
  28.         {
  29.             s = str;
  30.             InitializeComponent();
  31.         }
  32.         private void Pwd_Load(object sender, EventArgs e)
  33.         {
  34.             DLname c = DLname.getInstance();
  35.             textBox1.Text = c.Str;
  36.         }
  37.         private void button1_Click(object sender, EventArgs e)
  38.         {
  39.             string name = textBox1.Text.Trim().ToString();
  40.             string pwd = textBox2.Text.Trim().ToString();
  41.             if (textBox2.Text.Trim().Length==0 || textBox3.Text.Trim()!=textBox2.Text.Trim())
  42.             {
  43.                 MessageBox.Show("修改密码失败,两次密码不能为空或不相等!","系统提示");
  44.             }
  45.             else
  46.             {
  47.                 try
  48.                 {
  49.                     DBTools db = new DBTools(".", "wkdl", true, "sa", "wdxg");
  50.                     SqlDataReader b = db.getResult("update userlogin set uPassword='" + pwd + "'where uName='" + name + "'");
  51.                     db.Disconnect();
  52.                     b.Close();
  53.                     MessageBox.Show("密码修改成功!");
  54.                     this.Dispose(true);
  55.                 }
  56.                 catch (Exception x)
  57.                 {
  58.                     MessageBox.Show(x.Message);
  59.                 }
  60.             }
  61.         }
  62.         private void button2_Click(object sender, EventArgs e)
  63.         {
  64.             this.Dispose(true);
  65.         }
  66.     }
  67. }