FrmUsersLogin.cs 1.9 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Asa.FaceControl;
using System.Windows.Forms;
using BLL;

namespace SmartScan
{
    public partial class FrmUsersLogin : FaceFormFixed
    {
        private readonly BLL.UsersLogin usersLogin;

        public FrmUsersLogin()
        {
            InitializeComponent();
            usersLogin = new();
        }

        private void LoginSystem(string user, string pwd)
        {
            bool rtn = usersLogin.Logion(user, pwd, out Model.UserLevel level);
            if (rtn)
            {
                BLLCommon.config.UserName = user;
                BLLCommon.config.UserLevel = level;
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                FaceMessageBox msg = new("", Language.Dialog("LoginWrong"), MessageBoxButtons.OK)
                {
                    Icon = Properties.Resources.NEO_64
                };
                msg.ShowDialog();
            }
        }

        private void FacePwd_NumberEnter(object sender, string text)
        {
            LoginSystem(TxtUser.Text, FacePwd.Text);
        }

        private void BtnCancel_Click(object sender, EventArgs e)
        {
            Model.LogNet.log.Info("取消登录");
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void BtnLogin_Click(object sender, EventArgs e)
        {
            LoginSystem(TxtUser.Text, FacePwd.Text);
        }

        private void FrmUsersLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            usersLogin.Dispose();
        }

        private void FrmUsersLogin_Load(object sender, EventArgs e)
        {
            Model.LogNet.log.Info("显示登录界面");
        }
    }
}