- using System;
- 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.Data.SqlClient;
- namespace 人事管理系统
- {
- public partial class passwd_change : Form
- {
- Datacon mydatacon = new Datacon();
- password mypassword = new password();
- SqlConnection sqlcn = new SqlConnection();
- public passwd_change()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- sqlcn = mydatacon.getcon();
- sqlcn.Open();
- //SqlCommand cmd = new SqlCommand("查询员工号是否存在 '" + this.textBox1.Text + "'", sqlcn);
- //string q = cmd.ExecuteScalar().ToString();//用q记录该员工号是否存在
- //if (q == "0")
- //{
- // MessageBox.Show("该员工编号不存在,请重新输入!");
- // return;
- //}
- //else
- //{
- SqlCommand cnd = new SqlCommand("SELECT COUNT(*) FROM [PERSON] WHERE ID='"+label5.Text+"'and PASSWD='"+mypassword.OUT(this.textBox2.Text)+"'",sqlcn);
- string t = cnd.ExecuteScalar().ToString();//用t记录验证过后是否帐号与密码相符合
- if (t == "0")
- {
- MessageBox.Show("原始密码不正确,请重新输入!");
- return;
- }
- else
- {
- if (this.textBox3.Text == "" || this.textBox4.Text == "" || this.textBox3.Text!= this.textBox4.Text)
- {
- MessageBox.Show("两次新密码输入不一致,请重新输入!");
- return;
- }
- else
- {
- SqlCommand scd = new SqlCommand();
- scd.Connection = sqlcn;
- scd.CommandText = "修改密码 '" + mypassword.IN(this.textBox3.Text) + "','" + label5.Text + "'";
- scd.ExecuteNonQuery();//执行密码修改命令
- MessageBox.Show("密码修改成功!");
- sqlcn.Close();
- textBox2.Clear();
- textBox3.Clear();
- textBox4.Clear();
- }
- }
- }
- //}
- private void ShowForm1_Tick(object sender, EventArgs e)
- {
- if (this.Opacity == 1) //如果窗体透明度达到 1
- {
- this.ShowForm1.Stop();
- }
- else //透明度小于 1
- {
- this.Opacity = this.Opacity + 0.1; //透明度递增
- }
- }
- private void HideForm1_Tick(object sender, EventArgs e)
- {
- this.Opacity = this.Opacity - 0.1; //透明度不等于 0
- if (this.Opacity == 0) //透明度等于 0
- {
- this.HideForm1.Stop();
- this.Close();
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.HideForm1.Start();
- }
- private void passwd_change_Load(object sender, EventArgs e)
- {
- this.ShowForm1.Enabled = true; //控件是否激活
- this.ShowForm1.Interval = 50; //Elapsed 事件的频率
- //timer控件HideForm1
- this.HideForm1.Enabled = false;
- this.HideForm1.Interval = 30;
- this.Opacity = 0.0; //设置窗体透明度
- ShowForm1.Start();
- }
- }
- }