public void displayError(Config.status_t st) { switch (st) { case ERROR_FRM_NOT_EXIST: MessageBox.Show("Error", "Please contact the administrator. Your program needs fixing.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; case ERROR_LOGIC_VALIDATE: MessageBox.Show("Argument Error", "The information provided is wrong.", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case ERROR_TIME_ALARM_BEFORE_NOW: MessageBox.Show("Alarm Error", "The alarm cannot be before the current time.", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case ERROR_UKNOWN: // Don't handle this break; default: // MessageBox.Show("Error", "An error has occurred.", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
// Methods public Config.status_t storeAlarm(Alarm alarm) { Config.status_t st = ERROR_UKNOWN; try { List <string> alarmData = new List <string>(); // Data dump: Year, Month, Day, Hour, Minute, Second, Melody alarmData = alarm.dumpDataAsList(); if ((st = this.writeFile(this.alarmFilepath, alarmData, Config.FILE_FORMAT_CSV)) != OK) { return(st); } } catch (IOException IOEx) { throw IOEx; } catch (Exception Ex) { throw Ex; } return(st); }
public Config.status_t storeAlarm(Alarm alarm) { // Create file handler, Logic has no storeAlarm method because it is not pertinent. Filehandler fileH = new Filehandler(); Config.status_t st = ERROR_UKNOWN; // Call fileHandler to handle storage in files. try { if ((st = fileH.storeAlarm(alarm)) != OK) { return(st); } } catch (Exception ex) { throw ex; } return(st); }