예제 #1
0
        /// <summary>
        ///  辅助处理
        /// </summary>
        private void bbi_ItemClick(object sender, ItemClickEventArgs e)
        {
            string item = e.Item.Tag.ToString();

            switch (item)
            {
            case "ABOUT":
                FrmAbout aboutform = new FrmAbout();
                aboutform.WindowState = FormWindowState.Normal;
                aboutform.ShowDialog();
                break;

            case "HELP":
                string file = EnvInfo.RunPath + "Help\\index.html";
                try
                {
                    Help.ShowHelp(this, file);
                }
                catch
                {
                    MessageHelper.ShowError("打开帮助文件不成功。");
                }
                break;

            case "CALC":                       //  计算器
                Process pRunExeFile = new Process();
                pRunExeFile.StartInfo.FileName = System.Environment.SystemDirectory + "\\calc.exe";
                pRunExeFile.Start();
                break;

            case "DFM":
                FrmMenuDefault frmdfm = new FrmMenuDefault();
                frmdfm.ShowDialog();
                break;

            case "SQLM":
                FrmSQLMonitorWithMsg frmsm = new FrmSQLMonitorWithMsg();
                frmsm.MdiParent = this;
                frmsm.Init();
                frmsm.Show();
                break;

            case "PASSWORD":
                FrmPassword frmpw = new FrmPassword();
                frmpw.ShowDialog();
                break;

            case "EXIT":
                this.Close();
                break;

            case "CLOSECHILD":
                foreach (FrmBase frmmdi in this.MdiChildren)
                {
                    frmmdi.Close();
                }
                break;

            case "RELOGIN":
                if (this.MdiChildren.GetLength(0) > 0)
                {
                    MessageHelper.ShowWarning("还有未关闭窗口,请关闭后再转换!");
                    return;
                }

                LogHelper.Info(this, "退出系统 --- 停止定时器");
                this.timer1.Stop();

                LogHelper.Info(this, "退出系统 --- 关闭外部信息接口");
                infoRemoteAction.Close();

                LogHelper.Info(this, "退出系统 --- 关闭内部信息接口");
                infoLocalAction.Close();

                EmpInfo.Logout();
                LogHelper.Info(this, "退出系统完成");

                //  打开登录窗口, 成功后刷新界面
                FrmLogin frm_login = new FrmLogin();
                frm_login.Text = this.Title;
                if (frm_login.ShowDialog() == DialogResult.OK)
                {
                    this.Init();
                }
                else
                {
                    this.Close();
                }
                break;

            case "LOG0":
                LogHelper._logLevel      = 0;
                this.bciLogNone.Checked  = true;
                this.bciLogError.Checked = false;
                this.bciLogWarn.Checked  = false;
                this.bciLogDebug.Checked = false;
                this.bciLogInfo.Checked  = false;
                break;

            case "LOG1":
                LogHelper._logLevel      = 1;
                this.bciLogNone.Checked  = false;
                this.bciLogError.Checked = true;
                this.bciLogWarn.Checked  = false;
                this.bciLogDebug.Checked = false;
                this.bciLogInfo.Checked  = false;
                break;

            case "LOG2":
                LogHelper._logLevel      = 2;
                this.bciLogNone.Checked  = false;
                this.bciLogError.Checked = false;
                this.bciLogWarn.Checked  = true;
                this.bciLogDebug.Checked = false;
                this.bciLogInfo.Checked  = false;
                break;

            case "LOG3":
                LogHelper._logLevel      = 3;
                this.bciLogNone.Checked  = false;
                this.bciLogError.Checked = false;
                this.bciLogWarn.Checked  = false;
                this.bciLogDebug.Checked = true;
                this.bciLogInfo.Checked  = false;
                break;

            case "LOG4":
                LogHelper._logLevel      = 4;
                this.bciLogNone.Checked  = false;
                this.bciLogError.Checked = false;
                this.bciLogWarn.Checked  = false;
                this.bciLogDebug.Checked = false;
                this.bciLogInfo.Checked  = true;
                break;
            }
        }
예제 #2
0
        static void Main()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-Hans");
            //换肤
            BonusSkins.Register();
            SkinManager.EnableFormSkins();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!DevExpress.Skins.SkinManager.AllowFormSkins)
            {
                DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged();
                DevExpress.Skins.SkinManager.EnableFormSkins();
            }

            //设置应用程序处理异常方式:ThreadException处理
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += new ThreadExceptionEventHandler(AppThreadException);

            DisplayHelper.ShowWithLog(typeof(Program).FullName, "初始化", "正在初始化系统,请稍后...");

            //  判断系统是否已经运行,
            CheckRunning();

            try
            {
                string title = "Wonder医院信息管理系统V1.0";
                //获取分支机构
                if (EnvInfo.BranchId <= 0)
                {
                    MessageHelper.ShowError("分支机构ID未能获取,无法进入系统!");
                    Application.Exit();
                    return;
                }

                // 获取命令行信息
                string[] cmdline = Environment.GetCommandLineArgs();
                Dictionary <String, String> cmdInfos = new Dictionary <string, string>();
                if (cmdline.Length > 1)
                {
                    string cmdInfo = cmdline[1];
                    cmdInfos = GetInfos(cmdInfo);
                }

                bool   login = false;
                String token = string.Empty;
                cmdInfos.TryGetValue("Token", out token);
                if (!token.IsNullOrEmpty())
                {
                    //  token登录
                    login = EmpInfo.LoginWithToken(token);
                }

                if (!login)
                {
                    DisplayHelper.Hide();

                    //登录
                    FrmLogin frm_login = new FrmLogin();
                    frm_login.Text = title;

                    login = (frm_login.ShowDialog() == DialogResult.OK);
                }

                if (login)
                {
                    //if(EmpInfo.GetLastSystemCode() == "OPC")
                    //{
                    //    WindowsFormsSettings.DefaultFont = new Font(SystemFonts.DefaultFont.Name, 10);
                    //}
                    //else
                    //{
                    WindowsFormsSettings.DefaultFont = new Font(SystemFonts.DefaultFont.Name, SystemFonts.DefaultFont.Size);
                    //}

                    DisplayHelper.ShowWithLog(typeof(Program).FullName, "初始化", "正在创建主窗口...");

                    FrmMainRibbon frm = new FrmMainRibbon();
                    frm.Title = title;
                    frm.Init();

                    DisplayHelper.Close();
                    Application.Run(frm);
                }
            }
            catch (Exception ex)
            {
                DisplayHelper.Close();
                MessageHelper.ShowError(ex.Message + "\r\n" + ex.InnerException.Message);
                LogHelper.Error(typeof(Program).FullName, ex.Message + "\r\n" + ex.InnerException.Message + "\r\n" + ex.StackTrace);
            }
        }