CNAS取数仪器端升级
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

86 wiersze
2.4KB

  1. using CnasSynchronousCommon;
  2. using CnasSynchronusClient;
  3. using CnasSynchrousModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace CNAS_DBSync
  13. {
  14. public partial class frmLockPwd : Form
  15. {
  16. private bool isLocking;
  17. public frmLockPwd(bool isLocking)
  18. {
  19. InitializeComponent();
  20. this.isLocking = isLocking;
  21. this.Text = isLocking ? "锁定操作" : "解锁操作";
  22. }
  23. private void btnOK_Click(object sender, EventArgs e)
  24. {
  25. Config();
  26. }
  27. public void Config()
  28. {
  29. DataBaseInfo Cnasdb = FileOperation.GetLocalCnasDB();
  30. if (this.txtPwd.Text.Trim() == Cnasdb.DBPwd)
  31. {
  32. // 保存锁定状态
  33. LockStateOperation.SaveLockState(isLocking);
  34. this.DialogResult = DialogResult.OK;
  35. this.Close();
  36. }
  37. else
  38. {
  39. MessageBox.Show("密码无效。");
  40. }
  41. }
  42. private void frmLockPwd_KeyDown(object sender, KeyEventArgs e)
  43. {
  44. try
  45. {
  46. if (!btnOK.Focused)
  47. {
  48. FormKeyEventClass fke = new FormKeyEventClass();
  49. fke.FormKeyEvent += new FormKeyEventClass.FormKey(Config);
  50. fke.FormKeyEventRun(e);
  51. }
  52. }
  53. catch (Exception ex)
  54. {
  55. AppLog.Error(ex.Message.ToString());
  56. }
  57. }
  58. [System.Runtime.InteropServices.DllImport("user32.dll")]
  59. public static extern bool ReleaseCapture();
  60. [System.Runtime.InteropServices.DllImport("user32.dll")]
  61. public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
  62. public const int WM_SYSCOMMAND = 0x0112;
  63. public const int SC_MOVE = 0xF010;
  64. public const int HTCAPTION = 0x0002;
  65. private void frmLockPwd_MouseDown(object sender, MouseEventArgs e)
  66. {
  67. try
  68. {
  69. ReleaseCapture();
  70. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  71. }
  72. catch (Exception ex)
  73. {
  74. AppLog.Error(ex.Message.ToString());
  75. }
  76. }
  77. }
  78. }