示例#1
0
        private void tsbCancel_Click(object sender, EventArgs e)
        {
            if (ShowMessageHelper.ShowBoxMsg("您确定要注销系统吗?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
            {
                try
                {
                    //Program.CloseALLForm(this);
                    CloseForm();
                    this.Hide();
                }
                catch
                {
                }

                FrmLogon login = new FrmLogon();
                login.StartPosition = FormStartPosition.CenterParent;
                login.BringToFront();
                login.Focus();
                //login.TopMost = true;
                if (login.ShowDialog() == DialogResult.Cancel)
                {
                    closeTag = true;
                    dispTag  = false;
                    Application.Exit();
                }
                else
                {
                    if (login.bLogin)
                    {
                        //closeTag = true;
                        dispTag = false;

                        this.WindowState = FormWindowState.Maximized;
                        this.Show();
                        this.BringToFront();
                        this.Activate();
                        this.Focus();
                        SetStatuStrip();
                    }
                    login.Dispose();
                }
            }
        }
        static void Main(string[] args)
        {
            GlobalMutex();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //注册系统异常事件
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);


            string sendstring = "";

            if (args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    sendstring += args[i];
                }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FrmSendString(sendstring));//"201211301100"
            }
            else
            {
                //启动登陆界面
                FrmLogon dlg = new FrmLogon();
                dlg.StartPosition = FormStartPosition.CenterScreen;
                DialogResult result = dlg.ShowDialog();
                dlg.Focus();
                if (DialogResult.OK == result)
                {
                    if (dlg.bLogin)
                    {
                        FrmMain frmMain = new FrmMain();
                        frmMain.StartPosition = FormStartPosition.CenterScreen;
                        Application.Run(frmMain);
                    }
                }
                dlg.Dispose();
            }
        }