/// <summary>
        /// Searches for appointments that match the search criteria.
        /// </summary>
        public IRIS.Law.WebServiceInterfaces.Diary.Appointment[] SearchAppointment(int startRow, int pageSize, string sortBy, string user, string date, bool forceRefresh)
        {
            DiaryServiceClient diaryService = null;
            IRIS.Law.WebServiceInterfaces.Diary.Appointment[] appointments = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = forceRefresh;
                    collectionRequest.StartRow = startRow;
                    collectionRequest.RowCount = pageSize;

                    AppointmentSearchCriteria criteria = new AppointmentSearchCriteria();
                    criteria.MemberID = user;
                    criteria.OrderBy = sortBy;
                    if (!string.IsNullOrEmpty(date))
                    {
                        criteria.Date = Convert.ToDateTime(date);
                    }
                    else
                    {
                        criteria.Date = DataConstants.BlankDate;
                    }

                    diaryService = new DiaryServiceClient();
                    AppointmentSearchReturnValue returnValue = diaryService.AppointmentSearch(_logonId,
                                                collectionRequest, criteria);

                    if (returnValue.Success)
                    {
                        _appointmentRowCount = returnValue.Appointments.TotalRowCount;
                        appointments = returnValue.Appointments.Rows;
                    }
                    else
                    {
                        if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.")
                            throw new Exception("Date is invalid");
                        else
                            throw new Exception(returnValue.Message);
                    }
                }
                return appointments;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// This will fire after cancellation details has entered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void _dcAppointmentDelete_CancellationFinishedChanged(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(_dcAppointmentDelete.TaskAppointmentId.Trim()))
                {
                    // Delete Appointment
                    DeleteData deleteData = new DeleteData();
                    deleteData.CancellationText = _dcAppointmentDelete.CancellationText;
                    deleteData.ReasonCode       = _dcAppointmentDelete.ReasonCode;
                    deleteData.CategoryCode     = _dcAppointmentDelete.CategoryCode;
                    deleteData.OccurenceId      = Convert.ToInt32(_dcAppointmentDelete.TaskAppointmentId);
                    deleteData.MemberId         = _hdnUser.Value;
                    deleteData.IsBookingATask   = false;

                    DiaryServiceClient diaryService = null;
                    try
                    {
                        if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                        {
                            Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;


                            diaryService = new DiaryServiceClient();
                            ReturnValue returnValue = diaryService.DeleteBooking(_logonId, deleteData);

                            if (returnValue.Success)
                            {
                                BindAppointmentList();

                                _lblError.CssClass = "successMessage";
                                _lblError.Text     = "Appointment deleted successfully.";
                            }
                            else
                            {
                                throw new Exception(returnValue.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (diaryService != null)
                        {
                            if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                            {
                                diaryService.Close();
                            }
                        }
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text     = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.CssClass = "errorMessage";
                _lblError.Text     = ex.Message;
            }
        }
        private void LoadTaskDetails()
        {
            Guid projectId = DataConstants.DummyGuid;
            if (_hdnTaskId.Value.Trim().Length > 0)
            {
                DiaryServiceClient diaryService = new DiaryServiceClient();
                try
                {
                    TaskReturnValue  taskReturnValue = new TaskReturnValue();
                    //If Project Id for matter is null call method GetMemberTaskDetails, else call GetMatterTaskDetails
                    if (Session[SessionName.TaskProjectId] == null)
                    {
                        taskReturnValue = diaryService.GetMemberTaskDetails(_logonSettings.LogonId, Convert.ToInt32(_hdnTaskId.Value));
                    }
                    else
                    {
                        taskReturnValue = diaryService.GetMatterTaskDetails(_logonSettings.LogonId, new Guid(Convert.ToString(Session[SessionName.TaskProjectId])), Convert.ToInt32(_hdnTaskId.Value));
                    }
                    if (taskReturnValue.Success)
                    {
                        if (taskReturnValue != null)
                        {
                            _txtAttendees.Text = taskReturnValue.Task.AttendeesName;
                            _hdnAttendeesMemberId.Value = taskReturnValue.Task.Attendees;
                            _TaskOU.CurrentUsers = taskReturnValue.Task.AttendeesName;
                            _TaskOU.CurrentUsersID = taskReturnValue.Task.Attendees;
                            _txtSubject.Text = taskReturnValue.Task.Subject;
                            if (taskReturnValue.Task.DueDate != DataConstants.BlankDate)
                            {
                                _ccDueDate.DateText = Convert.ToString(taskReturnValue.Task.DueDate);
                            }
                            else
                            {
                                _ccDueDate.DateText = string.Empty;
                            }
                            _chkCompleted.Checked = taskReturnValue.Task.IsCompleted;
                            _chkExposeToThirdParties.Checked = taskReturnValue.Task.IsPublic;

                            if (_ddlType.Items.FindByValue(taskReturnValue.Task.TypeId.ToString()) != null)
                            {
                                _ddlType.SelectedIndex = -1;
                                _ddlType.Items.FindByValue(taskReturnValue.Task.TypeId.ToString()).Selected = true;
                            }

                            _txtNotes.Text = taskReturnValue.Task.Notes;

                            projectId = taskReturnValue.Task.ProjectId;
                            _hdnProjectId.Value = Convert.ToString(projectId);
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(taskReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }

                try
                {
                    if (projectId != DataConstants.DummyGuid)
                    {
                        //ViewState["TaskProjectId"] = projectId;
                        _cliMatDetails.ProjectId = projectId;
                        LoadClientMatterDetails(projectId);
                    }
                    else
                    {
                        _cliMatDetails.LoadData = false;
                        //ViewState["TaskProjectId"] = DataConstants.DummyGuid.ToString();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        private void GetDefaultFeeEarnerDetails()
        {
            DiaryServiceClient diaryService = null;
            _txtAttendees.Text = string.Empty;
            _hdnAttendeesMemberId.Value = string.Empty;
            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow = 0;
                collectionRequest.RowCount = 0;

                DiaryMemberSearchReturnValue returnValue = new DiaryMemberSearchReturnValue();
                returnValue = diaryService.GetDiaryMembers(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    for (int i = 0; i < returnValue.DiaryMembers.Rows.Length; i++)
                    {
                        if (_logonSettings.UserDefaultFeeMemberId.ToString() == returnValue.DiaryMembers.Rows[i].MemberID)
                        {
                            _txtAttendees.Text = _txtAttendees.Text + returnValue.DiaryMembers.Rows[i].MemberDisplayName + "; ";
                            _hdnAttendeesMemberId.Value += _hdnAttendeesMemberId.Value + returnValue.DiaryMembers.Rows[i].MemberID + "; ";
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
        }
        private void BindTaskTypes()
        {
            DiaryServiceClient diaryService = null;
            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow = 0;
                collectionRequest.RowCount = 0;

                DiaryParameterReturnValue returnValue = new DiaryParameterReturnValue();
                returnValue = diaryService.GetTaskTypes(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    _ddlType.DataSource = returnValue.DiaryParamters.Rows;
                    _ddlType.DataTextField = "Description";
                    _ddlType.DataValueField = "Id";
                    _ddlType.DataBind();

                    if (_logonSettings.UserType == (int)DataConstants.UserType.Client ||
                        _logonSettings.UserType == (int)DataConstants.UserType.ThirdParty)
                    {
                        for (int i = 0; i < _ddlType.Items.Count - 1; i++)
                        {
                            if (_ddlType.Items[i].Text != "Standard Task")
                            {
                                _ddlType.Items.RemoveAt(i);
                            }
                        }

                        _ddlType.Enabled = false;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
        }
        protected void _btnSave_Click(object sender, EventArgs e)
        {
            string errorMessage = CheckMandatoryFields();

            if (string.IsNullOrEmpty(errorMessage))
            {
                DiaryServiceClient diaryService = null;
                try
                {
                    IRIS.Law.WebServiceInterfaces.Diary.Task taskDetails = GetControlData();

                    diaryService = new DiaryServiceClient();
                    TaskReturnValue returnValue = diaryService.SaveTask(_logonSettings.LogonId, taskDetails);

                    if (returnValue.Success)
                    {
                        _hdnTaskId.Value = Convert.ToString(returnValue.Task.Id);

                        _lblError.CssClass = "successMessage";
                        _lblError.Text = "Task 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 = "Due 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 void GetDefaultFeeEarnerDetails()
        {
            DiaryServiceClient diaryService = null;
            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow = 0;
                collectionRequest.RowCount = 0;

                DiaryMemberSearchReturnValue returnValue = new DiaryMemberSearchReturnValue();
                returnValue = diaryService.GetDiaryMembers(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    for (int i = 0; i < returnValue.DiaryMembers.Rows.Length; i++)
                    {
                        if (_logonSettings.UserDefaultFeeMemberId.ToString() == returnValue.DiaryMembers.Rows[i].MemberID)
                        {
                            _ddlUsers.SelectedIndex = -1;
                            if (_ddlUsers.Items.FindByValue(_logonSettings.UserDefaultFeeMemberId.ToString()) != null)
                            {
                                _ddlUsers.Items.FindByValue(_logonSettings.UserDefaultFeeMemberId.ToString()).Selected = true;
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }

            if (_ddlUsers.SelectedValue == "")
            {
                _ddlUsers.SelectedIndex = 0;
            }
        }
        private void BindUsers()
        {
            DiaryServiceClient diaryService = null;
            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow = 0;
                collectionRequest.RowCount = 0;

                DiaryMemberSearchReturnValue returnValue = new DiaryMemberSearchReturnValue();
                returnValue = diaryService.GetDiaryMembers(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    _ddlUsers.DataSource = returnValue.DiaryMembers.Rows;
                    _ddlUsers.DataTextField = "MemberDisplayName";
                    _ddlUsers.DataValueField = "MemberID";
                    _ddlUsers.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
        }
        /// <summary>
        /// This will fire after cancellation details has entered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void _dcTaskDelete_CancellationFinishedChanged(object sender, EventArgs e)
        {
            try
            {

                if (!string.IsNullOrEmpty(_dcTaskDelete.TaskAppointmentId.Trim()))
                {
                    // Delete Appointment
                    DeleteData deleteData = new DeleteData();
                    deleteData.CancellationText = _dcTaskDelete.CancellationText;
                    deleteData.ReasonCode = _dcTaskDelete.ReasonCode;
                    deleteData.CategoryCode = _dcTaskDelete.CategoryCode;
                    deleteData.OccurenceId = Convert.ToInt32(_dcTaskDelete.TaskAppointmentId);
                    deleteData.MemberId = _hdnUser.Value;
                    deleteData.IsBookingATask = true;

                    DiaryServiceClient diaryService = null;
                    try
                    {
                        if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                        {
                            Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;

                            diaryService = new DiaryServiceClient();
                            ReturnValue returnValue = diaryService.DeleteBooking(_logonId, deleteData);

                            if (returnValue.Success)
                            {
                                BindTaskList();

                                _lblError.CssClass = "successMessage";
                                _lblError.Text = "Task deleted successfully.";
                            }
                            else
                            {
                                throw new Exception(returnValue.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (diaryService != null)
                        {
                            if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                                diaryService.Close();
                        }
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.CssClass = "errorMessage";
                _lblError.Text = ex.Message;
            }
        }
        /// <summary>
        /// Searches for tasks that match the search criteria.
        /// </summary>
        public IRIS.Law.WebServiceInterfaces.Diary.Task[] SearchTask(int startRow, int pageSize, string sortBy, string taskStatus, string user, string fromDate, string toDate, bool forceRefresh)
        {
            DiaryServiceClient diaryService = null;
            IRIS.Law.WebServiceInterfaces.Diary.Task[] tasks = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = forceRefresh;
                    collectionRequest.StartRow = startRow;
                    collectionRequest.RowCount = pageSize;

                    TaskSearchCriteria criteria = new TaskSearchCriteria();
                    criteria.MemberID = user;
                    criteria.OrderBy = sortBy;
                    if (Session[SessionName.ProjectId] != null)
                    {
                        criteria.ProjectID = new Guid(Session[SessionName.ProjectId].ToString());
                    }

                    if (!string.IsNullOrEmpty(fromDate))
                    {
                        criteria.StartDate = Convert.ToDateTime(fromDate);
                    }
                    else
                    {
                        criteria.StartDate = DataConstants.BlankDate;
                    }

                    if (!string.IsNullOrEmpty(toDate))
                    {
                        criteria.ToDate = Convert.ToDateTime(toDate);
                    }
                    else
                    {
                        criteria.ToDate = DataConstants.BlankDate;
                    }

                    if (!string.IsNullOrEmpty(taskStatus))
                    {
                        criteria.Status = taskStatus;
                    }

                    diaryService = new DiaryServiceClient();
                    TaskSearchReturnValue returnValue = diaryService.MatterTaskSearch(_logonId,
                                                collectionRequest, criteria);

                    if (returnValue.Success)
                    {
                        _taskRowCount = returnValue.Tasks.TotalRowCount;
                        tasks = returnValue.Tasks.Rows;
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                return tasks;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
        }
        /// <summary>
        /// Searches for task that match the search criteria.
        /// </summary>
        public IRIS.Law.WebServiceInterfaces.Diary.Task[] SearchTask(int startRow, int pageSize, string sortBy, string taskStatus, string user, string fromDate, string toDate, bool forceRefresh)
        {
            DiaryServiceClient diaryService = null;

            IRIS.Law.WebServiceInterfaces.Diary.Task[] tasks = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = forceRefresh;
                    collectionRequest.StartRow     = startRow;
                    collectionRequest.RowCount     = pageSize;

                    TaskSearchCriteria criteria = new TaskSearchCriteria();
                    criteria.MemberID = user;
                    criteria.OrderBy  = sortBy;
                    if (!string.IsNullOrEmpty(fromDate))
                    {
                        criteria.StartDate = Convert.ToDateTime(fromDate);
                    }
                    else
                    {
                        criteria.StartDate = DataConstants.BlankDate;
                    }

                    if (!string.IsNullOrEmpty(toDate))
                    {
                        criteria.ToDate = Convert.ToDateTime(toDate);
                    }
                    else
                    {
                        criteria.ToDate = DataConstants.BlankDate;
                    }

                    if (!string.IsNullOrEmpty(taskStatus))
                    {
                        criteria.Status = taskStatus;
                    }

                    diaryService = new DiaryServiceClient();
                    TaskSearchReturnValue returnValue = diaryService.MemberTaskSearch(_logonId,
                                                                                      collectionRequest, criteria);

                    if (returnValue.Success)
                    {
                        _taskRowCount = returnValue.Tasks.TotalRowCount;
                        tasks         = returnValue.Tasks.Rows;
                    }
                    else
                    {
                        if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.")
                        {
                            throw new Exception("Date is invalid");
                        }
                        else
                        {
                            throw new Exception(returnValue.Message);
                        }
                    }
                }
                return(tasks);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        diaryService.Close();
                    }
                }
            }
        }
        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 void LoadAppointmentDetails()
        {
            Guid projectId = DataConstants.DummyGuid;

            _hdnProjectId.Value = Convert.ToString(DataConstants.DummyGuid);
            if (_hdnAppointmentId.Value.Trim().Length > 0)
            {
                DiaryServiceClient diaryService = new DiaryServiceClient();
                try
                {
                    AppointmentReturnValue appointmentReturnValue = new AppointmentReturnValue();
                    appointmentReturnValue = diaryService.GetAppointmentDetails(_logonSettings.LogonId, Convert.ToInt32(_hdnAppointmentId.Value));

                    if (appointmentReturnValue.Success)
                    {
                        if (appointmentReturnValue != null)
                        {
                            _txtAttendees.Text            = appointmentReturnValue.Appointment.AttendeesName;
                            _hdnAttendeesMemberId.Value   = appointmentReturnValue.Appointment.Attendees;
                            _AppointmentOU.CurrentUsers   = appointmentReturnValue.Appointment.AttendeesName;
                            _AppointmentOU.CurrentUsersID = appointmentReturnValue.Appointment.Attendees;
                            _txtSubject.Text = appointmentReturnValue.Appointment.Subject;
                            _ssAppointmentVenue.ServiceText = appointmentReturnValue.Appointment.VenueText;
                            _hdnVenueId.Value     = Convert.ToString(appointmentReturnValue.Appointment.VenueId);
                            _ccDate.DateText      = Convert.ToString(appointmentReturnValue.Appointment.StartDate);
                            _tcStartTime.TimeText = appointmentReturnValue.Appointment.StartTime;
                            _tcEndTime.TimeText   = appointmentReturnValue.Appointment.EndTime;

                            _chkReminder.Checked = appointmentReturnValue.Appointment.IsReminderSet;

                            if (appointmentReturnValue.Appointment.IsReminderSet)
                            {
                                _ddlReminder.SelectedIndex = -1;
                                if (_ddlReminder.Items.FindByValue(appointmentReturnValue.Appointment.ReminderType) != null)
                                {
                                    _ddlReminder.Items.FindByValue(appointmentReturnValue.Appointment.ReminderType).Selected = true;
                                }

                                _ddlReminderBeforeTime.SelectedIndex = -1;
                                if (_ddlReminderBeforeTime.Items.FindByValue(appointmentReturnValue.Appointment.ReminderBeforeTime) != null)
                                {
                                    _ddlReminderBeforeTime.Items.FindByValue(appointmentReturnValue.Appointment.ReminderBeforeTime).Selected = true;
                                }

                                if (appointmentReturnValue.Appointment.ReminderType == "On")
                                {
                                    _tdReminderOn.Style["display"]     = "";
                                    _tdReminderBefore.Style["display"] = "none";
                                }
                                else
                                {
                                    _tdReminderOn.Style["display"]     = "none";
                                    _tdReminderBefore.Style["display"] = "";
                                }

                                _ccReminderDate.DateText = Convert.ToString(appointmentReturnValue.Appointment.ReminderDate);
                                _tcReminderTime.TimeText = appointmentReturnValue.Appointment.ReminderTime;
                            }
                            else
                            {
                                _ddlReminder.SelectedIndex           = -1;
                                _ddlReminderBeforeTime.SelectedIndex = -1;
                                _ccReminderDate.DateText             = string.Empty;
                                _tcReminderTime.TimeText             = string.Empty;
                            }

                            _txtNotes.Text = appointmentReturnValue.Appointment.Notes;

                            projectId           = appointmentReturnValue.Appointment.ProjectId;
                            _hdnProjectId.Value = Convert.ToString(projectId);

                            HideUnhideReminderControls();
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(appointmentReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        diaryService.Close();
                    }
                }

                try
                {
                    if (projectId != DataConstants.DummyGuid)
                    {
                        _cliMatDetails.ProjectId = projectId;
                        LoadClientMatterDetails(projectId);
                    }
                    else
                    {
                        _cliMatDetails.LoadData = false;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        private void BindReasonType()
        {
            DiaryServiceClient diaryService = null;
            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow = 0;
                collectionRequest.RowCount = 0;

                CancellationCodeSearchReturnValue returnValue = new CancellationCodeSearchReturnValue();
                returnValue = diaryService.GetBookingCancelledReasons(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    _ddlReason.DataSource = returnValue.CancellationCodes.Rows;
                    _ddlReason.DataTextField = "Description";
                    _ddlReason.DataValueField = "Code";
                    _ddlReason.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
            //try
            //{
            //    _ddlReason.DataSource = DataTables.GetReasonType();
            //    _ddlReason.DataTextField = "reason";
            //    _ddlReason.DataValueField = "reason";
            //    _ddlReason.DataBind();
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
        private void LoadTaskDetails()
        {
            Guid projectId = DataConstants.DummyGuid;

            if (_hdnTaskId.Value.Trim().Length > 0)
            {
                DiaryServiceClient diaryService = new DiaryServiceClient();
                try
                {
                    TaskReturnValue taskReturnValue = new TaskReturnValue();
                    //If Project Id for matter is null call method GetMemberTaskDetails, else call GetMatterTaskDetails
                    if (Session[SessionName.TaskProjectId] == null)
                    {
                        taskReturnValue = diaryService.GetMemberTaskDetails(_logonSettings.LogonId, Convert.ToInt32(_hdnTaskId.Value));
                    }
                    else
                    {
                        taskReturnValue = diaryService.GetMatterTaskDetails(_logonSettings.LogonId, new Guid(Convert.ToString(Session[SessionName.TaskProjectId])), Convert.ToInt32(_hdnTaskId.Value));
                    }
                    if (taskReturnValue.Success)
                    {
                        if (taskReturnValue != null)
                        {
                            _txtAttendees.Text          = taskReturnValue.Task.AttendeesName;
                            _hdnAttendeesMemberId.Value = taskReturnValue.Task.Attendees;
                            _TaskOU.CurrentUsers        = taskReturnValue.Task.AttendeesName;
                            _TaskOU.CurrentUsersID      = taskReturnValue.Task.Attendees;
                            _txtSubject.Text            = taskReturnValue.Task.Subject;
                            if (taskReturnValue.Task.DueDate != DataConstants.BlankDate)
                            {
                                _ccDueDate.DateText = Convert.ToString(taskReturnValue.Task.DueDate);
                            }
                            else
                            {
                                _ccDueDate.DateText = string.Empty;
                            }
                            _chkCompleted.Checked            = taskReturnValue.Task.IsCompleted;
                            _chkExposeToThirdParties.Checked = taskReturnValue.Task.IsPublic;

                            if (_ddlType.Items.FindByValue(taskReturnValue.Task.TypeId.ToString()) != null)
                            {
                                _ddlType.SelectedIndex = -1;
                                _ddlType.Items.FindByValue(taskReturnValue.Task.TypeId.ToString()).Selected = true;
                            }

                            _txtNotes.Text = taskReturnValue.Task.Notes;

                            projectId           = taskReturnValue.Task.ProjectId;
                            _hdnProjectId.Value = Convert.ToString(projectId);
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(taskReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        diaryService.Close();
                    }
                }

                try
                {
                    if (projectId != DataConstants.DummyGuid)
                    {
                        //ViewState["TaskProjectId"] = projectId;
                        _cliMatDetails.ProjectId = projectId;
                        LoadClientMatterDetails(projectId);
                    }
                    else
                    {
                        _cliMatDetails.LoadData = false;
                        //ViewState["TaskProjectId"] = DataConstants.DummyGuid.ToString();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }