ChangePwd.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES.DataOperate;
  11. using UAS_MES.Entity;
  12. using UAS_MES.PublicMethod;
  13. namespace UAS_MES.PublicForm
  14. {
  15. public partial class ChangePwd : CustomControl.BaseForm.BaseForm
  16. {
  17. //所有用到了headBar的部分都需要这段代码
  18. [DllImport("user32.dll")]
  19. public static extern bool ReleaseCapture();
  20. [DllImport("user32.dll")]
  21. public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
  22. [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
  23. public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
  24. [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
  25. public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);
  26. public const int WM_SYSCOMMAND = 0x0112;
  27. public const int SC_MOVE = 0xF010;
  28. public const int HTCAPTION = 0x0002;
  29. DataHelper dh;
  30. string ErrorMessage;
  31. public ChangePwd()
  32. {
  33. InitializeComponent();
  34. }
  35. private void Confirm_Click(object sender, EventArgs e)
  36. {
  37. if (LogicHandler.CheckUserLogin(UserName.Text, pwd.Text, out ErrorMessage))
  38. {
  39. ErrorMessage = "";
  40. String[] password = new string[1];
  41. String[] username = new string[1];
  42. password[0] = newpwd.Text;
  43. username[0] = UserName.Text.ToUpper();
  44. string SQL1 = "update employee set em_password = :passowrd where upper(em_code)= :emcode ";
  45. dh.BatchInsert(SQL1, new string[] { "passowrd", "emcode" }, password, username);
  46. MessageBox.Show("修改密码成功");
  47. Close();
  48. }
  49. else
  50. MessageBox.Show(ErrorMessage);
  51. }
  52. private void ChangePwd_Load(object sender, EventArgs e)
  53. {
  54. dh = SystemInf.dh;
  55. UserName.Text = BaseUtil.GetCacheData("LastLoginUser").ToString();
  56. Confirm.Enabled = false;
  57. }
  58. private void checkpwd_TextChanged(object sender, EventArgs e)
  59. {
  60. if (!(checkpwd.Text != "" && checkpwd.Text == newpwd.Text))
  61. {
  62. Confirm.Enabled = false;
  63. }
  64. else {
  65. Confirm.Enabled = true;
  66. }
  67. }
  68. private void headBar1_MouseDown(object sender, MouseEventArgs e)
  69. {
  70. ReleaseCapture();
  71. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  72. }
  73. }
  74. }