private void saveHoliday() { if (isHolidayValid()) { HolidayItem item = new HolidayItem(); item._HOLIDAY_NAME = tbHolidayName.Text; item._HOLIDAY_DATE = (DateTime)dpHolidayDate.SelectedDate; item._HOLIDAY_TYPE = cbHolidayType.SelectedValue.ToString(); try { HolidayManager hm = new HolidayManager(); hm.SaveHoliday(item); MessageBox.Show("New Holiday added."); } catch (System.Exception) { MessageBox.Show("Server not responding."); } HolidayCollection holidayList = new HolidayCollection(); holidayList.RetreiveAllHolidays(); Close(); } }
private void updateHoliday() { if (!string.IsNullOrEmpty(tbHolidayName.Text)) { HolidayItem item = new HolidayItem(); item._HOLIDAY_ID = selectedHolidayId; item._HOLIDAY_NAME = tbHolidayName.Text; item._HOLIDAY_DATE = (DateTime)dpHolidayDate.SelectedDate; item._HOLIDAY_TYPE = cbHolidayType.SelectedValue.ToString(); try { HolidayManager hm = new HolidayManager(); hm.UpdateHoliday(item); MessageBox.Show("Holiday successfully updated."); } catch (System.Exception) { MessageBox.Show("Server not responding."); } HolidayCollection holidayList = new HolidayCollection(); holidayList.RetreiveAllHolidays(); Close(); } else { MessageBox.Show("Please input holiday name."); } }
private void EnterEditMode(int mholidayId) { isEditMode = true; selectedHolidayId = mholidayId; HolidayItem selectedHoliday = (HolidayItem)StaticHolidayCollection.staticHolidayList.Where(t => t._HOLIDAY_ID.Equals(mholidayId)).FirstOrDefault(); tbHolidayName.Text = selectedHoliday._HOLIDAY_NAME; dpHolidayDate.SelectedDate = selectedHoliday._HOLIDAY_DATE; cbHolidayType.SelectedValue = (HolidayType)Enum.Parse(typeof(HolidayType), selectedHoliday._HOLIDAY_TYPE); ChangeButtonAppearance(); }