private void Login() { try { Cursor.Current = Cursors.WaitCursor; sa_t_operator_i oper = new sa_t_operator_i() { oper_id = this.txtOperId.Text, oper_pw = this.txtPwd.Text }; IBLL.IOper bll = new BLL.OperBLL(); if (bll.Login(oper)) { Program.oper = oper; InI.Writue("app", "oper_id", oper.oper_id); this.DialogResult = DialogResult.Yes; this.Close(); } else { new MsgForm("账号/密码错误").ShowDialog(); } } catch (Exception e) { LogHelper.writeLog("frmLogin", e.ToString()); MsgForm.ShowFrom(e); } finally { Cursor.Current = Cursors.Default; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // path = Application.StartupPath; //注册表 Registry(); // Helper.Appsetting.path = Application.StartupPath; Helper.Appsetting.app_ini(); //处理未捕获的异常 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //处理非UI线程异常 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); try { //验证程序 //if (SoftUpdate.VerifySoft() != 1) //{ // MessageBox.Show("没有找到加密狗!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // System.Environment.Exit(0); //} //检查服务器 IBLL.ICommonBLL bll = new BLL.CommonBLL(); if ("0".Equals(bll.IsServer())) { //var frmFindServer = new MainForm.frmFindServer(); //frmFindServer.ShowDialog(); MsgForm.ShowFrom("无法连接到服务器,请检查服务器连接"); return; } //更新中间件 手动验证 if (!Debugger.IsAttached) { SoftUpdate.Upadte(); } //检查机号 frmRegister frmreg = new frmRegister(); if (frmreg.RegisterJH() == DialogResult.Yes) { InitB2B(); frmLogin frm = new frmLogin(); if (frm.GoLogin() == DialogResult.Yes) { b2bclient.Program.oper_id = oper.oper_id; b2bclient.Program.pwd = oper.oper_pw; b2bclient.Program.op_type = oper.oper_type; Application.Run(new frmMain()); } } } catch (Exception e) { string str = ""; string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now + "\r\n"; if (e != null) { str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n", e.GetType().Name, e.Message, e.StackTrace); } else { str = string.Format("应用程序线程错误:{0}", e); } LogHelper.writeLog("Main", str); MessageBox.Show("系统错误!Message:" + e.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } System.Environment.Exit(0); }
public static void ShowFrom(Exception e) { MsgForm msg = new MsgForm(e.GetMessage()); msg.ShowDialog(); }
public static void ShowFrom(string text) { MsgForm msg = new MsgForm(text); msg.ShowDialog(); }