passwd_change.cs
上传用户:zhongfine
上传日期:2022-08-01
资源大小:2860k
文件大小:4k
源码类别:

企业管理

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;
  10. namespace 人事管理系统
  11. {
  12.     public partial class passwd_change : Form
  13.     {
  14.         Datacon mydatacon = new Datacon();
  15.         password mypassword = new password();
  16.         SqlConnection sqlcn = new SqlConnection();
  17.         public passwd_change()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.        
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             sqlcn = mydatacon.getcon();
  25.             sqlcn.Open();
  26.             //SqlCommand cmd = new SqlCommand("查询员工号是否存在 '" + this.textBox1.Text + "'", sqlcn);
  27.             //string q = cmd.ExecuteScalar().ToString();//用q记录该员工号是否存在
  28.             //if (q == "0")
  29.             //{
  30.             //    MessageBox.Show("该员工编号不存在,请重新输入!");
  31.             //    return;
  32.             //}
  33.             //else 
  34.             //{
  35.                 SqlCommand cnd = new SqlCommand("SELECT COUNT(*) FROM [PERSON] WHERE ID='"+label5.Text+"'and PASSWD='"+mypassword.OUT(this.textBox2.Text)+"'",sqlcn);
  36.                 string t = cnd.ExecuteScalar().ToString();//用t记录验证过后是否帐号与密码相符合
  37.                 if (t == "0")
  38.                 {
  39.                     MessageBox.Show("原始密码不正确,请重新输入!");
  40.                     return;
  41.                 }
  42.                 else
  43.                 {
  44.                     if (this.textBox3.Text == "" || this.textBox4.Text == "" || this.textBox3.Text!= this.textBox4.Text)
  45.                     {
  46.                         MessageBox.Show("两次新密码输入不一致,请重新输入!");
  47.                         return;
  48.                     }
  49.                     else
  50.                     {
  51.                         SqlCommand scd = new SqlCommand();
  52.                         scd.Connection = sqlcn;
  53.                         scd.CommandText = "修改密码 '" + mypassword.IN(this.textBox3.Text) + "','" + label5.Text + "'";
  54.                         scd.ExecuteNonQuery();//执行密码修改命令
  55.                         MessageBox.Show("密码修改成功!");
  56.                         sqlcn.Close();
  57.                         textBox2.Clear();
  58.                         textBox3.Clear();
  59.                         textBox4.Clear();
  60.                     }
  61.                 }
  62.             }
  63.         //}
  64.         private void ShowForm1_Tick(object sender, EventArgs e)
  65.         {
  66.             if (this.Opacity == 1)  //如果窗体透明度达到 1
  67.             {
  68.                 this.ShowForm1.Stop();
  69.             }
  70.             else  //透明度小于 1
  71.             {
  72.                 this.Opacity = this.Opacity + 0.1; //透明度递增
  73.             }
  74.         }
  75.         private void HideForm1_Tick(object sender, EventArgs e)
  76.         {
  77.             this.Opacity = this.Opacity - 0.1; //透明度不等于 0
  78.             if (this.Opacity == 0) //透明度等于 0
  79.             {
  80.                 this.HideForm1.Stop();
  81.                 this.Close();
  82.             }
  83.         }
  84.         private void button2_Click(object sender, EventArgs e)
  85.         {
  86.             this.HideForm1.Start();
  87.         }
  88.         private void passwd_change_Load(object sender, EventArgs e)
  89.         {
  90.             this.ShowForm1.Enabled = true; //控件是否激活
  91.             this.ShowForm1.Interval = 50; //Elapsed 事件的频率
  92.             //timer控件HideForm1
  93.             this.HideForm1.Enabled = false;
  94.             this.HideForm1.Interval = 30;
  95.             this.Opacity = 0.0;  //设置窗体透明度
  96.             ShowForm1.Start(); 
  97.         }
  98.     }
  99. }