Ejemplo n.º 1
0
        private void addAlarmButton_Click(object sender, EventArgs e)
        {
            AlarmForm alarmForm = new AlarmForm();

            bool loopReturn = true;
            do
            {
                DialogResult dialogResult = alarmForm.ShowDialog();

                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    bool existsCheck = _alarms.Search(alarmForm.Alarm.AlarmTime);

                    if (existsCheck == true)
                    {
                        alarmForm.SetErrorLabel();
                        alarmForm.ShowDialog();
                    }

                    else
                    {
                        _alarms.Add(alarmForm.Alarm);
                        loopReturn = false;
                        refreshAlarmList();
                    }
                }
            } while (loopReturn == true && alarmForm.DialogResult != System.Windows.Forms.DialogResult.Cancel);
        }
Ejemplo n.º 2
0
        private void editAlarmButton_Click(object sender, EventArgs e)
        {
            AlarmForm alarmForm = new AlarmForm(_alarms.GetAlarm(alarmsListBox.SelectedIndex));

            bool loopReturn = true;
            do
            {
                DialogResult dialogResult = alarmForm.ShowDialog();

                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    DateTime checkDate = alarmForm.Alarm.AlarmTime;
                    bool existsCheck;
                    _alarms.Search(checkDate, out existsCheck, out checkDate);

                    if (existsCheck == true && checkDate != alarmForm.Alarm.AlarmTime)
                    {
                        alarmForm.SetErrorLabel();
                        alarmForm.ShowDialog();
                    }

                    if (existsCheck == false || checkDate == alarmForm.Alarm.AlarmTime)
                    {
                        _alarms.Delete(alarmsListBox.SelectedIndex);
                        _alarms.Add(alarmForm.Alarm);
                        loopReturn = false;
                    }
                }
                refreshAlarmList();
            } while (loopReturn == true && alarmForm.DialogResult != System.Windows.Forms.DialogResult.Cancel);
        }