예제 #1
0
        //=====================================================================

        /// <summary>
        /// Add a new holiday to the list box
        /// </summary>
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            using(HolidayPropertiesDlg dlg = new HolidayPropertiesDlg())
            {
                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    holidays.Add(dlg.HolidayInfo);
                    this.LoadHolidayList();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Edit a holiday entry in the list box
        /// </summary>
        private void btnEdit_Click(object sender, System.EventArgs e)
        {
            if(lbHolidays.SelectedIndex == -1)
            {
                MessageBox.Show(LR.GetString("EditHMSelectHoliday"));
                return;
            }

            using(HolidayPropertiesDlg dlg = new HolidayPropertiesDlg())
            {
                // The dialog takes care loading data from the object
                dlg.HolidayInfo = holidays[lbHolidays.SelectedIndex];

                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    // Replace the holiday with the edited information.  Because the type may change, the
                    // add/edit dialog returns a new instance.
                    holidays[lbHolidays.SelectedIndex] = dlg.HolidayInfo;
                    this.LoadHolidayList();
                }
            }
        }