ChangePwd.cs 2.7 KB

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