FrmLogin.cs 2.4 KB
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineStore.ACSingleStore
{
    public partial class FrmLogin : FrmBase
    {
        private string UserName = "admin".ToUpper();
        private string UserPwd = "123456".ToUpper();
        public FrmLogin()
        {
            string aa = ConfigAppSettings.GetValue(Setting_Init.UserName);
            string ww = ConfigAppSettings.GetValue(Setting_Init.UserPwd);
            if (!aa.Equals(""))
            {
                UserName = aa.ToUpper();
            }
            if (!ww.Equals(""))
            {
                UserPwd = ww;
            }
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string pwd = txtPwd.Text.Trim();
            if (userName.ToUpper().Equals(UserName) && UserPwd.Equals(pwd))
            {
                FrmStoreBox lineStore = new FrmStoreBox();
                this.Hide();
                lineStore.ShowDialog();
                this.Close();
            }
            else
            {
                if (!(userName.ToUpper().Equals(UserName)))
                {
                    MessageBox.Show("请输入正确的用户名!");
                    txtUserName.Text = "";
                    txtUserName.Focus();
                }
                else
                {
                    MessageBox.Show("请输入正确的密码!");
                    txtPwd.Focus();
                    txtPwd.Text = "";
                }
            }
        }

        private void FrmLogin_Load(object sender, EventArgs e)
        {
            this.AcceptButton = btnLogin;
            string title = OnlineStore.Common.ConfigAppSettings.GetValue(Setting_Init.App_Title);
            this.Text = title;
            txtUserName.Focus();


            int sizeH = this.Size.Height;
            int sizeW = this.Size.Width;

            int locationH=((sizeH-panel1.Size.Height)/2);
            int locationW = (sizeH - panel1.Size.Width) / 2;
            panel1.Size = new Size(locationW, locationH);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}