frmlock.cs

来自「酒店管理系统,您酒店物业管理的好帮手」· CS 代码 · 共 92 行

CS
92
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Hotel.Operation;

namespace Hotel.UI
{
    public partial class frmLock : Form
    {
        
        private Point mouseOffset;
        private Point mousePos;
        public bool isPwd = false;
        UserInfoAccess objUserInfoAccess = null;
        public frmLock()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //关闭系统
            DialogResult dr = MessageBox.Show("是否关闭系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if(dr==DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void txtPwd_KeyPress(object sender, KeyPressEventArgs e)
        {
            //按回车键确定
            if (e.KeyChar == (char)13)
                btnUndo_Click(sender, e);
        }

        private void btnUndo_Click(object sender, EventArgs e)
        {
            string pwd = txtPwd.Text.Trim();
            objUserInfoAccess = new UserInfoAccess();

            //判断用户输入是否为空
            if (txtPwd.Text == string.Empty)
            {

                MessageBox.Show("密码不能为空,请输入密码!","提示");
            }
            //判断用户输入的密码是否正确
            else if (objUserInfoAccess.LockPwd(pwd))
            {
                isPwd = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("您输入的密码是错误的,请重新输入!", "提示");
                txtPwd.Focus();
            }
            { 
                
            
            }
        }

        private void frmLock_Load(object sender, EventArgs e)
        {
            this.ActiveControl = txtPwd;
        }

        private void frmLock_MouseDown(object sender, MouseEventArgs e)
        {
            mouseOffset = new Point(-e.X, -e.Y);
        }

        private void frmLock_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            { 
                
                //是否左击

                mousePos = Control.MousePosition;
                mousePos.Offset(mouseOffset.X, mouseOffset.Y);
                Location = mousePos;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?