コード例 #1
0
        private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            var ex = e.Exception;

            MsgBoxLib.ShowError(ex.Message);
            LogHelper.WriteErrorLog(ex, "UI Exception");
        }
コード例 #2
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            MsgBoxLib.ShowError(ex.Message);
            LogHelper.WriteErrorLog(ex, "non-UI Exception", $"Runtime terminating: {e.IsTerminating}");
        }
コード例 #3
0
        private void btnSaveMes_Click(object sender, EventArgs e)
        {
            var dbInfo = new DbInfo
            {
                Name   = DbInfoName.MainDb,
                DbType = (SqlSugar.DbType)Enum.Parse(typeof(SqlSugar.DbType),
                                                     cmbMES.SelectedItem as string ?? throw new InvalidOperationException()),
                DataSource = txtMESServer.Text,
                DbName     = txtMESDbName.Text,
                Port       = Convert.ToInt32(txtMESPort.Text),
                UserId     = txtMESUser.Text,
                Password   = txtMESPswd.Text
            };

            try
            {
                dbInfo.Update();
                MsgBoxLib.ShowInformationOk("保存成功,重启后生效");
            }
            catch (Exception ex)
            {
                MsgBoxLib.ShowError($"保存失败\n错误信息:{ex.Message}");
            }
        }
    }
コード例 #4
0
ファイル: LoginDialog.cs プロジェクト: ChenglongMa/DNA_MES
 private void btnLogin_Click(object sender, System.EventArgs e)
 {
     _user.EmpId    = txtId.Text.Trim();
     _user.Password = txtPwd.Text;
     if (LoginBll.CanLogin(_user))
     {
         DialogResult = DialogResult.OK;
     }
     else
     {
         MsgBoxLib.ShowError("用户名/密码错误,请重试");
     }
 }
コード例 #5
0
            RootPath = Directory.GetCurrentDirectory(); //AppDomain.CurrentDomain.BaseDirectory;

        /// <summary>
        ///     创建日志文件夹
        /// </summary>
        /// <returns></returns>
        private static string CreateLogDirectory(string path, string strfile)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (!File.Exists(path + strfile))
                {
                    File.Create(path + strfile).Dispose();
                }
                return(path + strfile);
            }
            catch (Exception ex)
            {
                MsgBoxLib.ShowError(ex.Message);
                return(null);
            }
        }
コード例 #6
0
 private void btnDBInitial_Click(object sender, EventArgs e)
 {
     if (MsgBoxLib.ShowQuestion("该操作将删除现有的数据,是否继续?"))
     {
         Cursor.Current = Cursors.WaitCursor;
         try
         {
             Application.DoEvents();
             //bslMesDbInit.InitialMESDatabase();
             MsgBoxLib.ShowInformationOk("操作结束!");
         }
         catch (Exception ex)
         {
             Cursor.Current = Cursors.Default;
             MsgBoxLib.ShowError(ex.Message);
         }
         finally
         {
             Cursor.Current = Cursors.Default;
         }
     }
 }
コード例 #7
0
        private void btnTestMes_Click(object sender, EventArgs e)
        {
            var dbInfo = new DbInfo
            {
                Name   = DbInfoName.MainDb,
                DbType = (SqlSugar.DbType)Enum.Parse(typeof(SqlSugar.DbType),
                                                     cmbMES.SelectedItem as string ?? throw new InvalidOperationException()),
                DataSource = txtMESServer.Text,
                DbName     = txtMESDbName.Text,
                UserId     = txtMESUser.Text,
                Port       = Convert.ToInt32(txtMESPort.Text),
                Password   = txtMESPswd.Text
            };

            if (DbConfigHelper.TestConnection(dbInfo, out var errorMessage))
            {
                MsgBoxLib.ShowInformationOk("连接成功");
            }
            else
            {
                MsgBoxLib.ShowError($"连接失败\n错误信息:\n{errorMessage}");
            }
        }