private void btn_CreateEvent_Click(object sender, RoutedEventArgs e) { if (txt_AddTitle.Text.Equals("")) { return; } BLL.CalendarEvent calEvent = new BLL.CalendarEvent(0); calEvent.Title = txt_AddTitle.Text; calEvent.Detail = txt_AddDetail.Text; DateTime eventTime = new DateTime(currentDay.Date.Year, currentDay.Date.Month, currentDay.Date.Day); string input = txt_AddTime.Text; String[] time = input.Split(':'); if (Int32.Parse(time[0]) >= 24 || Int32.Parse(time[1]) >= 60) { return; } eventTime = eventTime.AddHours(Int32.Parse(time[0])); eventTime = eventTime.AddMinutes(Int32.Parse(time[1])); calEvent.CalendarDate = eventTime; if (Model.CalendarEvent.Insert(calEvent) > 0) { txt_AddTitle.Text = ""; txt_AddDetail.Text = ""; txt_AddTime.Text = "00:00"; grd_CreateEvent.Height = 0; } parent.UpdateCalendarDates(); UpdateEvents(); }
private void lst_Events_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (lst_Events.SelectedValue == null) { return; } BLL.CalendarEvent calEvent = (BLL.CalendarEvent)lst_Events.SelectedValue; txt_EditTitle.Text = calEvent.Title; txt_EditDetail.Text = calEvent.Detail; txt_EditTime.Text = calEvent.CalendarDate.ToString("HH:mm"); }
private void btn_Delete_Click(object sender, RoutedEventArgs e) { if (lst_Events.SelectedValue == null) { return; } BLL.CalendarEvent calEvent = (BLL.CalendarEvent)lst_Events.SelectedValue; Model.CalendarEvent.Delete(calEvent.GetId()); parent.UpdateCalendarDates(); UpdateEvents(); }
private void btn_EditEventConfirm_Click(object sender, RoutedEventArgs e) { //shouldn't be possible but hey.. if (lst_Events.SelectedValue == null) { return; } BLL.CalendarEvent selectedEvent = (BLL.CalendarEvent)lst_Events.SelectedValue; BLL.CalendarEvent editEvent = new BLL.CalendarEvent(selectedEvent.GetId()); editEvent.Title = txt_EditTitle.Text; editEvent.Detail = txt_EditDetail.Text; DateTime eventTime = new DateTime(currentDay.Date.Year, currentDay.Date.Month, currentDay.Date.Day); string input = txt_EditTime.Text; String[] time = input.Split(':'); if (Int32.Parse(time[0]) >= 24 || Int32.Parse(time[1]) >= 60) { return; } eventTime = eventTime.AddHours(Int32.Parse(time[0])); eventTime = eventTime.AddMinutes(Int32.Parse(time[1])); editEvent.CalendarDate = eventTime; if (Model.CalendarEvent.Update(editEvent)) { grd_EditEvent.Height = 0; txbl_EditButtonText.Text = "Edit"; } parent.UpdateCalendarDates(); UpdateEvents(); }