//登录 private void tsmiLogin_Click(object sender, EventArgs e) { ILogger.Write(EnumLogType.OperateLog, strLogPath + DateTime.Now.ToString("yyyy-MM-dd") + ".xml", LoginBLL.user, "打开登录菜单"); A_FrmLogin frm = new A_FrmLogin(this); frm.ShowDialog(); this.stsUsername.Text = "用户名:" + LoginBLL.user; this.stsLoginTime.Text = "登录时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); }
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 } }