using System; using System.Runtime.InteropServices; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.PublicForm { public partial class ChangePwd : CustomControl.BaseForm.BaseForm { //所有用到了headBar的部分都需要这段代码 [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)] public static extern int GetWindowLong(HandleRef hWnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)] public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x0002; DataHelper dh; string ErrorMessage; public ChangePwd() { InitializeComponent(); } private void Confirm_Click(object sender, EventArgs e) { if (LogicHandler.CheckUserLogin(UserName.Text, pwd.Text, out ErrorMessage)) { ErrorMessage = ""; String[] password = new string[1]; String[] username = new string[1]; password[0] = newpwd.Text; username[0] = UserName.Text.ToUpper(); string SQL1 = "update employee set em_password = :passowrd where upper(em_code)= :emcode "; dh.BatchInsert(SQL1, new string[] { "passowrd", "emcode" }, password, username); MessageBox.Show("修改密码成功"); Close(); } else MessageBox.Show(ErrorMessage); } private void ChangePwd_Load(object sender, EventArgs e) { dh = SystemInf.dh; UserName.Text = BaseUtil.GetCacheData("LastLoginUser").ToString(); Confirm.Enabled = false; } private void checkpwd_TextChanged(object sender, EventArgs e) { if (!(checkpwd.Text != "" && checkpwd.Text == newpwd.Text)) { Confirm.Enabled = false; } else { Confirm.Enabled = true; } } private void headBar1_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } } }