Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (窗口.修改密码 != null)
     {
     }
     else
     {
         修改密码 修改密码 = new 修改密码();
     }
     窗口.修改密码.Show();
     if (this.WindowState != FormWindowState.Minimized)
     {
         if (窗口.GetValue("默认大小") == "1")
         {
             窗口.修改密码.WindowState = FormWindowState.Normal;
         }
         else if (窗口.GetValue("默认大小") == "2")
         {
             窗口.修改密码.WindowState = FormWindowState.Maximized;
         }
         else
         {
             窗口.修改密码.WindowState = this.WindowState;
         }
     }
     else
     {
         if (窗口.GetValue("默认大小") == "2")
         {
             窗口.修改密码.WindowState = FormWindowState.Maximized;
         }
         else
         {
             窗口.修改密码.WindowState = FormWindowState.Normal;
         }
     }
     窗口.修改密码.Focus();
     this.Hide();
 }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     //焦点复位
     textBox1.Focus();
     try
     {
         //删除所有 .jpg和.png格式的文件
         DirectoryInfo di = new DirectoryInfo(Application.StartupPath);
         foreach (FileInfo fi in di.GetFiles())
         {
             string exname = fi.Name.Substring(fi.Name.LastIndexOf(".") + 1);//得到后缀名
             //判断当前文件后缀名是否与给定后缀名一样
             if (exname == "jpg" || exname == "png" || exname == "JPG" || exname == "PNG")
             {
                 File.Delete(Application.StartupPath + "\\" + fi.Name);//删除当前文件
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     try
     {
         //查询密码 工号是否正确
         OleDbCommand cmd = 窗口.conn.CreateCommand();
         cmd.CommandText = " select * from 人员信息 where 工号='" + textBox1.Text.Trim() + "'and 密码='" + textBox2.Text.Trim() + "'";
         OleDbDataReader reader = cmd.ExecuteReader();
         if (!reader.Read())
         {
             MessageBox.Show("用户名或密码错误", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             textBox2.Text = "";
             textBox2.Focus();
         }
         else
         {
             窗口.ID = textBox1.Text.Trim();  //正确则将工号写入全局变量备用
             if (!File.Exists(窗口.ip + 窗口.add + "\\已登录\\" + 窗口.ID))
             {
                 FileStream fs = new FileStream(窗口.ip + 窗口.add + "\\已登录\\" + 窗口.ID, FileMode.OpenOrCreate);
                 fs.Close();
             }
             else
             {
                 File.Delete(窗口.ip + 窗口.add + "\\已登录\\" + 窗口.ID);
                 System.Threading.Thread.Sleep(1000);
                 FileStream fs = new FileStream(窗口.ip + 窗口.add + "\\已登录\\" + 窗口.ID, FileMode.OpenOrCreate);
                 fs.Close();
             }
             if (checkBox1.Checked == true)
             {
                 窗口.SetValue("用户名", textBox1.Text);
                 窗口.SetValue("密码", 窗口.EncryptDES((textBox2.Text), "74110968"));
                 窗口.SetValue("记住密码", "1");
             }
             else
             {
                 窗口.SetValue("用户名", "");
                 窗口.SetValue("密码", "");
                 窗口.SetValue("记住密码", "0");
             }
             if (checkBox2.Checked == true)
             {
                 窗口.SetValue("自动登录", "1");
             }
             else
             {
                 窗口.SetValue("自动登录", "0");
             }
             if (textBox2.Text.Trim() == "123456")
             {
                 //是默认密码则要求修改密码
                 MessageBox.Show("密码为默认密码,请修改!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 员工自助查询 A    = new 员工自助查询();
                 修改密码   修改密码 = new 修改密码();
                 this.Hide();
                 修改密码.Show();
                 if (窗口.GetValue("默认大小") == "1")
                 {
                     修改密码.WindowState = FormWindowState.Normal;
                 }
                 else if (窗口.GetValue("默认大小") == "2")
                 {
                     修改密码.WindowState = FormWindowState.Maximized;
                 }
                 else
                 {
                     修改密码.WindowState = this.WindowState;
                 }
             }
             else
             {
                 员工自助查询 A = new 员工自助查询();
                 this.Hide();
                 等待 等待 = new 等待();
                 等待.Show();
                 A.Show();
                 if (窗口.GetValue("默认大小") == "1")
                 {
                     A.WindowState = FormWindowState.Normal;
                 }
                 else if (窗口.GetValue("默认大小") == "2")
                 {
                     A.WindowState = FormWindowState.Maximized;
                 }
                 else
                 {
                     A.WindowState = this.WindowState;
                 }
             }
         }
     }
     catch
     {
     }
 }