ChangePwd.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  29. }
  30. private void Confirm_Click(object sender, EventArgs e)
  31. {
  32. if (LogicHandler.CheckUserLogin(UserName.Text, pwd.Text,SystemInf.CurrentDB ,out ErrorMessage))
  33. {
  34. ErrorMessage = "";
  35. String[] password = new string[1];
  36. String[] username = new string[1];
  37. password[0] = newpwd.Text;
  38. username[0] = UserName.Text.ToUpper();
  39. string SQL1 = "update employee set em_password = :passowrd where upper(em_code)= :emcode ";
  40. dh.BatchInsert(SQL1, new string[] { "passowrd", "emcode" }, password, username);
  41. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("修改密码成功"));
  42. Close();
  43. }
  44. else
  45. MessageBox.Show(ErrorMessage);
  46. }
  47. private void ChangePwd_Load(object sender, EventArgs e)
  48. {
  49. dh = SystemInf.dh;
  50. UserName.Text = BaseUtil.GetCacheData("LastLoginUser").ToString();
  51. Confirm.Enabled = false;
  52. }
  53. private void checkpwd_TextChanged(object sender, EventArgs e)
  54. {
  55. if (!(checkpwd.Text != "" && checkpwd.Text == newpwd.Text))
  56. {
  57. Confirm.Enabled = false;
  58. }
  59. else {
  60. Confirm.Enabled = true;
  61. }
  62. }
  63. private void headBar1_MouseDown(object sender, MouseEventArgs e)
  64. {
  65. ReleaseCapture();
  66. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  67. }
  68. }
  69. }