bug
lu
7 天以前 98e93a53c3407b9785eba27faec13fe7afc1255b
DevApp/Gs.DevApp/DevFrm/FrmLogin.cs
@@ -18,18 +18,23 @@
{
    public partial class FrmLogin : XtraForm
    {
        private string _productName = "";
        private string _version = "未知";
        private string _strFont = "";
        private string _webApiUrl = "";
        public FrmLogin()
        {
            InitializeComponent();
            _productName = ConfigurationManager.AppSettings["ProductName"];
            _webApiUrl = ConfigurationManager.AppSettings["WebApiUrl"];
            if (ConfigurationManager.AppSettings["IsAutoUpdater"] == "1")
                _autoUpdate();
            _getFont();
            _getRemember();
            Text = lbVersion.Text = ConfigurationManager.AppSettings["ProductName"];
            btnLogin.Click += BtnLogin_Click;
            btnCancel.Click += BtnCancel_Click;
            lbVersion.Text = _productName + ",版本(" + _version + ")" + ",使用字体(" + _strFont + ")" + ",服务地址(" + _webApiUrl + ")";
        }
        private void BtnCancel_Click(object sender, EventArgs e)
@@ -45,7 +50,6 @@
                txtUser.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtPwd.Text.Trim()))
            {
                MsgHelper.Warning("密码不能为空!");
@@ -70,6 +74,7 @@
                    Settings.Default.userName = ckRemember.Checked ? txtUser.Text.Trim() : "";
                    Settings.Default.userPwd = ckRemember.Checked ? txtPwd.Text.Trim() : "";
                    Settings.Default.remember = ckRemember.Checked;
                    Settings.Default.isWeight = ckWeight.Checked;
                    Settings.Default.Save();
                    LoginInfoModel.CurrentUser.LoginUserGuid = _login["loginGuid"].ToString();
                    LoginInfoModel.CurrentUser.LoginTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm");
@@ -84,7 +89,7 @@
            catch (Exception ex)
            {
                DialogResult = DialogResult.Cancel;
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -95,17 +100,16 @@
        {
            try
            {
                if (Settings.Default.remember)
                {
                    txtUser.Text = Settings.Default.userName;
                    txtPwd.Text = Settings.Default.userPwd;
                    ckRemember.Checked = true;
                }
                txtUser.Text = Settings.Default.userName;
                txtPwd.Text = Settings.Default.userPwd;
                ckRemember.Checked = Settings.Default.remember;
                ckWeight.Checked = Settings.Default.isWeight;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 读取字体
@@ -114,10 +118,10 @@
        {
            try
            {
                string strFont = Settings.Default.fontSizeName;
                if (string.IsNullOrEmpty(strFont))
                _strFont = Settings.Default.fontSizeName;
                if (string.IsNullOrEmpty(_strFont))
                    return;
                string[] ary = strFont.Split(',');
                string[] ary = _strFont.Split(',');
                if (ary.Length < 2)
                    return;
                float _ft = float.Parse(ary[1]);
@@ -128,18 +132,20 @@
                DevExpress.XtraEditors.WindowsFormsSettings.DefaultPrintFont = new System.Drawing.Font(ary[0], _ft);
                #endregion
            }
            catch (Exception)
            catch (Exception ex)
            {
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        #region 自动更新
        private void _autoUpdate()
        {
            var _version = ConfigurationManager.AppSettings["Version"];
            _version = ConfigurationManager.AppSettings["Version"];
            AutoUpdater.InstalledVersion = new Version(_version);
            AutoUpdater.Start(ConfigurationManager.AppSettings["AutoUpdaterXml"]);
            AutoUpdater.CheckForUpdateEvent += AutoUpdater_CheckForUpdateEvent;
        }
        private void AutoUpdater_CheckForUpdateEvent(UpdateInfoEventArgs args)
        {
            if (args == null || string.IsNullOrEmpty(args.DownloadURL))
@@ -149,12 +155,10 @@
                Application.Exit();
                return;
            }
            if (!args.IsUpdateAvailable)
            {
                return;
            }
            var _strMsg =
                string.Format(
                    $@"有新版本 {args.CurrentVersion} 可用,您使用的是 {args.InstalledVersion}版本,这是必需的更新,按“是(Y)”开始更新应用程序。");
@@ -164,7 +168,6 @@
                Application.Exit();
                return;
            }
            try
            {
                if (AutoUpdater.DownloadUpdate(args))
@@ -186,7 +189,6 @@
                        config.Save(ConfigurationSaveMode.Modified);
                        ConfigurationManager.RefreshSection("appSettings");
                    }
                    Application.Exit();
                }
                else
@@ -204,6 +206,13 @@
            }
        }
        #endregion
        /// <summary>
        /// 读取mac
        /// </summary>
        /// <returns></returns>
        private string GetMacAddress()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();