|
- using CnasSynchronousCommon;
- using CnasSynchronusClient;
- using CnasSynchrousModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
-
- namespace CNAS_DBSync
- {
- public partial class frmLockPwd : Form
- {
- private bool isLocking;
-
- public frmLockPwd(bool isLocking)
- {
- InitializeComponent();
- this.isLocking = isLocking;
- this.Text = isLocking ? "锁定操作" : "解锁操作";
- }
-
- private void btnOK_Click(object sender, EventArgs e)
- {
- Config();
- }
-
- public void Config()
- {
- DataBaseInfo Cnasdb = FileOperation.GetLocalCnasDB();
- if (this.txtPwd.Text.Trim() == Cnasdb.DBPwd)
- {
- // 保存锁定状态
- LockStateOperation.SaveLockState(isLocking);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageBox.Show("密码无效。");
- }
- }
-
- private void frmLockPwd_KeyDown(object sender, KeyEventArgs e)
- {
- try
- {
- if (!btnOK.Focused)
- {
- FormKeyEventClass fke = new FormKeyEventClass();
- fke.FormKeyEvent += new FormKeyEventClass.FormKey(Config);
- fke.FormKeyEventRun(e);
- }
- }
- catch (Exception ex)
- {
- AppLog.Error(ex.Message.ToString());
- }
- }
-
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- public static extern bool ReleaseCapture();
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
- public const int WM_SYSCOMMAND = 0x0112;
- public const int SC_MOVE = 0xF010;
- public const int HTCAPTION = 0x0002;
-
- private void frmLockPwd_MouseDown(object sender, MouseEventArgs e)
- {
- try
- {
- ReleaseCapture();
- SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
- }
- catch (Exception ex)
- {
- AppLog.Error(ex.Message.ToString());
- }
- }
- }
- }
|