Exemplo n.º 1
0
        //退出系统
        private void tsmLogin_Exit_Click(object sender, EventArgs e)
        {

            if (LoginBLL.user.Equals("KJ128AORKJ128N"))
            {
                // 终止定时打印线程
                th.Abort();
            }
            else if (LoginBLL.user == "guest")
            {

                DialogResult dre = MessageBox.Show("你没有权限关闭本软件,如想关闭本软件,请重先登录!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dre == DialogResult.Yes)
                {
                    FrmLogin frm = new FrmLogin();
                    frm.ShowDialog();
                }
            }
            else
            {
                DialogResult dre = MessageBox.Show("关闭本软件时,是否需要关闭通讯程序?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                //if (dre == DialogResult.No)
                //{
                //    e.Cancel = true;
                //    return;
                //}
                if (dre == DialogResult.Yes)
                {
                    #region 关闭通讯程序

                    foreach (Process process in Process.GetProcesses())
                    {
                        if (process.ProcessName.Equals("KJ128A.Batman"))
                        {
                            try
                            {
                                process.Kill();
                            }
                            catch { }
                            break;
                        }
                    }

                    #endregion
                }

                #region [保存界面布局]

                // 保存界面布局
                //string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");
                //if (m_bSaveLayout)
                //{
                //    dockPanel1.SaveAsXml(configFile);
                //}
                //else if (File.Exists(configFile))
                //{
                //    File.Delete(configFile);
                //}

                #endregion

                // 终止定时打印线程
                th.Abort();


                #region 退出应用程序进程

                Process p = Process.GetCurrentProcess();
                p.CloseMainWindow();
                if (!p.HasExited)
                {
                    p.Kill();
                }

                #endregion
            }
        }
Exemplo n.º 2
0
        //登录
        private void tsmLogin_Login_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(this.tsmLogin_Login.OwnerItem.Name);

            ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "打开登录菜单");

            FrmLogin frm = new FrmLogin();
            frm.ShowDialog();
        }