private void muteAlarmBtn_Click(object sender, EventArgs e) { smsTrigger = 1; DBConnector dBConn = new DBConnector(); dBConn.connect(); AlarmHandler alarmHandler = new AlarmHandler(); int id = alarmHandler.getLastId(dBConn.getConn(), BedsideLoginScreen.bedside_patient_id); int result = alarmHandler.updateDateTimeMuted(dBConn.getConn(), BedsideLoginScreen.bedside_patient_id, id); if (id > 0) { if (result == 1) { BedsideHandler bedsideHandler = new BedsideHandler(); int alarmResult = bedsideHandler.updateAlarmStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 0); if (alarmResult == 1) { int alarmResultZero = bedsideHandler.updateAlarmZeroStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 0); if (alarmResultZero == 1) { MessageBox.Show("Muted Alarm", "Muted Alarm", MessageBoxButtons.OK, MessageBoxIcon.Information); alarmReadingStatus = false; alarmZeroStatus = false; if (backgroundWorkerAlarmReading.IsBusy) { backgroundWorkerAlarmReading.CancelAsync(); } if (backgroundWorkerAlarmZero.IsBusy) { backgroundWorkerAlarmZero.CancelAsync(); } backgroundWorkerBeep.RunWorkerAsync(); } } } else { MessageBox.Show("Alarm cannot be muted", "Muted Alarm", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private async void readTemperatureData() { kayChart dataChart = new kayChart(temperatureLineGraph, 60); dataChart.serieName = "Temperature"; string path = "../../../Patient-Monitoring-System/data files/temperatureCSV.csv"; string line; try { StreamReader sr = new StreamReader(path); line = sr.ReadLine(); while (line != null) { string[] columns = line.Split(','); foreach (string column in columns) { if (run) { double value = double.Parse(column); //add each value to database *DONT Delete* DateTime currentDate = DateTime.Now; DateTime currentTime = DateTime.Now; DBConnector dBConn = new DBConnector(); dBConn.connect(); Temperature newTemperature = new Temperature(); newTemperature.TemperatureValue = value; newTemperature.TemperatureDate = currentDate; newTemperature.TemperatureTime = currentTime; TemperatureHandler temperatureHandler = new TemperatureHandler(); ReadingHandler readingHandler = new ReadingHandler(); int result = temperatureHandler.addNewTemperature(dBConn.getConn(), newTemperature, BedsideLoginScreen.bedside_patient_id); if (result != 1) { MessageBox.Show("Insert Data failed"); } await Task.Delay(1500); await Task.Factory.StartNew(() => { dataChart.TriggeredUpdate(value); }); if (value == 0) { if (smsTrigger == 1) { if (!backgroundWorkerSendSMS.IsBusy) { backgroundWorkerSendSMS.RunWorkerAsync(); } } temperatureLineGraph.Series["Temperature"].Color = Color.Red; temperatureCurrentValue.ForeColor = Color.Red; BedsideHandler bedsideHandler = new BedsideHandler(); int alarmResult = bedsideHandler.updateAlarmZeroStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1); alarmZeroStatus = true; AlarmHandler alarmHandler = new AlarmHandler(); int specificId = alarmHandler.getSpecificId(dBConn.getConn(), value, "temperature"); if (specificId > 0) { bool triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, 0, specificId, "Temperature"); if (triggerStatus) { listTemperature.Add(newTemperature); } } } else if (value >= double.Parse(maxTemperatureLabel.Text) || value <= double.Parse(minTemperatureLabel.Text)) { if (smsTrigger == 1) { if (!backgroundWorkerSendSMS.IsBusy) { backgroundWorkerSendSMS.RunWorkerAsync(); } } temperatureLineGraph.Series["Temperature"].Color = Color.Yellow; temperatureCurrentValue.ForeColor = Color.Yellow; BedsideHandler bedsideHandler = new BedsideHandler(); int alarmResult = bedsideHandler.updateAlarmStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1); alarmReadingStatus = true; int id = readingHandler.getIdAlarmTrigger(dBConn.getConn(), value); if (id > 0) { AlarmHandler alarmHandler = new AlarmHandler(); bool triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, id, 0, "Temperature"); if (triggerStatus) { listTemperature.Add(newTemperature); } } } else { temperatureLineGraph.Series["Temperature"].Color = Color.Green; temperatureCurrentValue.ForeColor = Color.Green; } temperatureCurrentValue.Text = value.ToString() + "°C"; } else { break; } } line = sr.ReadLine(); } } catch (FileNotFoundException e) { MessageBox.Show(e.ToString()); Console.WriteLine(e.ToString()); } }