private void IsAlarm() { try { //判断是否有求救信息 string strEmpHelpCount = rtehbll.GetEmpHelpCounts().ToString(); if (Convert.ToInt32(strEmpHelpCount) > 0) { if (frmRteh == null) { try { frmRteh = new FrmFlash(); frmRteh.GetCount(strEmpHelpCount); frmRteh.Show(); } catch { } } else { frmRteh.GetCount(strEmpHelpCount); } //为窗体赋焦点 // frmRteh.Activate(); } else { if (frmRteh != null) { frmRteh.Close(); frmRteh.Dispose(); frmRteh = null; } } DataTable dt; //blIsAlarmErr = false; foreach (Control cl in cpAlram.Controls) { LinkLabel ll; switch (cl.Text) { case "超时报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(1)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(1); if (dt != null && dt.Rows.Count > 0) { AlarmSound(1, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "区域报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(2)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(2); if (dt != null && dt.Rows.Count > 0) { AlarmSound(2, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "传输分站故障报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(3)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(3); if (dt != null && dt.Rows.Count > 0) { AlarmSound(3, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "超员报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(4)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(4); if (dt != null && dt.Rows.Count > 0) { AlarmSound(4, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "低电量报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(5)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(5); if (dt != null && dt.Rows.Count > 0) { AlarmSound(5, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "读卡分站故障报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(6)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(6); if (dt != null && dt.Rows.Count > 0) { AlarmSound(6, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "工作异常报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(7)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(7); if (dt != null && dt.Rows.Count > 0) { AlarmSound(7, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; default: break; } } } catch { return; } }
private void IsAlarm() { try { //判断是否有求救信息 string strEmpHelpCount = rtehbll.GetEmpHelpCounts().ToString(); if (Convert.ToInt32(strEmpHelpCount) > 0) { if (frmRteh == null) { try { frmRteh = new FrmFlash(); frmRteh.GetCount(strEmpHelpCount); frmRteh.Show(); } catch { } } else { frmRteh.GetCount(strEmpHelpCount); } //为窗体赋焦点 // frmRteh.Activate(); } else { if (frmRteh != null) { frmRteh.Close(); frmRteh.Dispose(); frmRteh = null; } } DataTable dt; //blIsAlarmErr = false; foreach (Control cl in cpAlram.Controls) { LinkLabel ll; switch (cl.Text) { case "超时报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(1)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(1); if (dt != null && dt.Rows.Count > 0) { AlarmSound(1, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "区域报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(2)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(2); if (dt != null && dt.Rows.Count > 0) { AlarmSound(2, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "传输分站故障报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(3)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(3); if (dt != null && dt.Rows.Count > 0) { AlarmSound(3, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "超员报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(4)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(4); if (dt != null && dt.Rows.Count > 0) { AlarmSound(4, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "低电量报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(5)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(5); if (dt != null && dt.Rows.Count > 0) { AlarmSound(5, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "读卡分站故障报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(6)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(6); if (dt != null && dt.Rows.Count > 0) { AlarmSound(6, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; case "工作异常报警": ll = (LinkLabel)cl; if (mbll.IsAlarm(7)) { ll.LinkColor = Color.Red; using (dt = new DataTable()) { dt = mbll.LoadAlarmPath(7); if (dt != null && dt.Rows.Count > 0) { AlarmSound(7, dt); } } } else { ll.LinkColor = Color.FromArgb(0, 0, 255); ll.Enabled = false; } break; default: break; } } } catch { return; } }