| | |
| | | { |
| | | 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) |
| | |
| | | txtUser.Focus(); |
| | | return; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(txtPwd.Text.Trim())) |
| | | { |
| | | MsgHelper.Warning("密码不能为空!"); |
| | |
| | | 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"); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | DialogResult = DialogResult.Cancel; |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | MsgHelper.ShowError("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | 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> |
| | | /// 读取字体 |
| | |
| | | { |
| | | 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]); |
| | |
| | | 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)) |
| | |
| | | Application.Exit(); |
| | | return; |
| | | } |
| | | |
| | | if (!args.IsUpdateAvailable) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var _strMsg = |
| | | string.Format( |
| | | $@"有新版本 {args.CurrentVersion} 可用,您使用的是 {args.InstalledVersion}版本,这是必需的更新,按“是(Y)”开始更新应用程序。"); |
| | |
| | | Application.Exit(); |
| | | return; |
| | | } |
| | | |
| | | try |
| | | { |
| | | if (AutoUpdater.DownloadUpdate(args)) |
| | |
| | | config.Save(ConfigurationSaveMode.Modified); |
| | | ConfigurationManager.RefreshSection("appSettings"); |
| | | } |
| | | |
| | | Application.Exit(); |
| | | } |
| | | else |
| | |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取mac |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private string GetMacAddress() |
| | | { |
| | | System.Text.StringBuilder sb = new System.Text.StringBuilder(); |