private void SaveButtonClick(object sender) { if (this.isProperAppointment()) { MyAppointment.Title = NewTitle; //MyAppointment.Message = NewMessage; MyAppointment.StartTime = new DateTime(MyAppointment.StartTime.Year, MyAppointment.StartTime.Month, MyAppointment.StartTime.Day, NewFromH, NewFromM, 0); MyAppointment.EndTime = new DateTime(MyAppointment.StartTime.Year, MyAppointment.StartTime.Month, MyAppointment.StartTime.Day, NewToH, NewToM, 0); try { if (!OldEvent) { CalendarModel.AddAppointment(MyAppointment); } else { CalendarModel.UpdateAppointment(MyAppointment); } ((Window)sender).Close(); } catch (Exception e) { Error = true; ErrorText = "Unfortunely appointment did not save becouse of " + e.Message + ". Please refresh"; } } }