protected void _btnSave_Click(object sender, EventArgs e) { string errorMessage = CheckMandatoryFields(); if (string.IsNullOrEmpty(errorMessage)) { DiaryServiceClient diaryService = null; try { IRIS.Law.WebServiceInterfaces.Diary.Appointment appointmentDetails = GetControlData(); diaryService = new DiaryServiceClient(); AppointmentReturnValue returnValue = diaryService.SaveAppointment(_logonSettings.LogonId, appointmentDetails); if (returnValue.Success) { _hdnAppointmentId.Value = Convert.ToString(returnValue.Appointment.Id); _lblError.CssClass = "successMessage"; _lblError.Text = "Appointment Saved Successfully."; } else { _lblError.CssClass = "errorMessage"; if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.") { _lblError.Text = "Date is invalid"; } else { _lblError.Text = returnValue.Message; } } } catch (System.ServiceModel.EndpointNotFoundException) { _lblError.Text = DataConstants.WSEndPointErrorMessage; _lblError.CssClass = "errorMessage"; } catch (Exception ex) { _lblError.CssClass = "errorMessage"; _lblError.Text = ex.Message; } finally { if (diaryService != null) { if (diaryService.State != System.ServiceModel.CommunicationState.Faulted) { diaryService.Close(); } } } } else { _lblError.CssClass = "errorMessage"; _lblError.Text = errorMessage; } }
private IRIS.Law.WebServiceInterfaces.Diary.Appointment GetControlData() { IRIS.Law.WebServiceInterfaces.Diary.Appointment appointmentDetails = new IRIS.Law.WebServiceInterfaces.Diary.Appointment(); try { if (_hdnAppointmentId.Value.Trim().Length > 0) { appointmentDetails.Id = Convert.ToInt32(_hdnAppointmentId.Value); } else { appointmentDetails.Id = 0; } appointmentDetails.ProjectId = DataConstants.DummyGuid; if (_hdnProjectId.Value.Length > 0) { appointmentDetails.ProjectId = new Guid(_hdnProjectId.Value); } if (_txtAttendees.Text.Length > 0) { appointmentDetails.Attendees = _hdnAttendeesMemberId.Value; } if (string.IsNullOrEmpty(_tcStartTime.TimeText)) { appointmentDetails.StartTime = ":"; } else { appointmentDetails.StartTime = _tcStartTime.TimeText; } if (string.IsNullOrEmpty(_tcEndTime.TimeText)) { appointmentDetails.EndTime = ":"; } else { appointmentDetails.EndTime = _tcEndTime.TimeText; } try { appointmentDetails.StartDate = Convert.ToDateTime(_ccDate.DateText); } catch { throw new Exception("Invalid Date"); } appointmentDetails.Notes = _txtNotes.Text; appointmentDetails.Subject = _txtSubject.Text; if (_hdnVenueId.Value.Trim().Length > 0) { appointmentDetails.VenueId = new Guid(_hdnVenueId.Value); } if (_chkReminder.Checked) { appointmentDetails.IsReminderSet = _chkReminder.Checked; appointmentDetails.ReminderDate = Convert.ToDateTime(_ccReminderDate.DateText); appointmentDetails.ReminderTime = _tcReminderTime.TimeText; appointmentDetails.ReminderType = _ddlReminder.SelectedValue; if (_ddlReminder.SelectedValue == "Before") { appointmentDetails.ReminderBeforeTime = _ddlReminderBeforeTime.SelectedValue; } else { appointmentDetails.ReminderBeforeTime = "0"; } } } catch (Exception ex) { throw ex; } return(appointmentDetails); }