Exemple #1
0
        //关闭
        private void tsmiClose_Click(object sender, EventArgs e)
        {
            A_FrmExit frme = new A_FrmExit();
            DialogResult dir = frme.ShowDialog();

            if (dir == DialogResult.Cancel)
            {
                //用户取消关闭系统      
                return;
            }
            else if (dir == DialogResult.OK)
            {
                //用户需要挂包通讯程序

                #region【关闭通讯程序】

                foreach (Process process in Process.GetProcesses())
                {
                    if (process.ProcessName.Equals("KJ128A.Batman"))
                    {
                        try
                        {
                            process.Kill();
                            ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "关闭KJ128A矿用人员管理系统,并关闭通讯程序!");
                        }
                        catch { }
                        // break;
                    }

                    ///Czlt-2010-9-29关闭其他外挂程序!
                    if (hashPlugins.ContainsValue(process.ProcessName))
                    {
                        process.Kill();
                        //Czlt-2010-9-29-添加声光报警器的日志
                        ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "关闭KJ128A矿用人员管理系统,并关闭" + process.ProcessName + "!");
                    }

                    //关闭Kj128保护程序
                    if (process.ProcessName.Equals("Kj128ChkHost"))
                    {
                        try
                        {
                            process.Kill();
                        }
                        catch { }

                    }
                }

                #endregion

                //#region 【Czlt-2011-12-26 软件正常关闭时修改配置信息,并关闭KJ128诊断软件】
                //CzltSaveChkXml(true, true);
                //#endregion

                //Czlt-2010-9-29-注销
                // ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "关闭KJ128A矿用人员管理系统,并关闭通讯程序!");
            }
            else
            {
                #region 【Czlt-2011-12-26 软件正常关闭时修改配置信息,并关闭KJ128诊断软件】
                //CzltSaveChkXml(true, false);
                #endregion
                ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "关闭KJ128A矿用人员管理系统!");

            }

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

            #region【关闭主界面程序】

            Process p = Process.GetCurrentProcess();
            p.Kill();

            #endregion
        }
Exemple #2
0
        private void A_FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {


            if (LoginBLL.user.Equals("KJ128AORKJ128N"))
            {

                // 终止定时打印线程
                // th.Abort();
            }
            else if (LoginBLL.user == "guest" && !New_DBAcess.blIsClient)
            {
                DialogResult dre = MessageBox.Show("你没有权限关闭本软件,如想关闭本软件,请重先登录!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dre == DialogResult.Yes)
                {
                    A_FrmLogin frm = new A_FrmLogin(this);
                    frm.ShowDialog();
                }
                e.Cancel = true;
            }
            else
            {
                A_FrmExit frme = new A_FrmExit();

                DialogResult dir = frme.ShowDialog();

                if (dir == DialogResult.Cancel)
                {
                    //用户取消关闭系统
                    e.Cancel = true;
                    return;
                }
                else if (dir == DialogResult.OK)
                {
                    //用户需要挂包通讯程序

                    #region【关闭通讯程序】

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

                        //关闭Kj128保护程序                      
                        if (process.ProcessName.Equals("Kj128ChkHost"))
                        {
                            try
                            {
                                process.Kill();
                            }
                            catch { }

                        }
                    }

                    #endregion

                    //#region 【Czlt-2011-12-26 软件正常关闭时修改配置信息,并关闭KJ128诊断软件】
                    //CzltSaveChkXml(true, true);
                    //#endregion

                    ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "关闭KJ128A矿用人员管理系统,并关闭通讯程序!");
                }
                else
                {

                    //#region 【Czlt-2011-12-26 软件正常关闭时修改配置信息,并关闭KJ128诊断软件】
                    //CzltSaveChkXml(true, false);                  
                    //#endregion

                    ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "关闭KJ128A矿用人员管理系统!");

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

                #region【关闭主界面程序】

                Process p = Process.GetCurrentProcess();
                p.Kill();

                #endregion
            }
        }