/// <summary> /// This method will post the selected timesheet entries for accounting /// </summary> /// <param name="displayWarnings">if set to <c>true</c> display warnings.</param> private void PostTime(bool displayWarnings) { TimeServiceClient timeService = null; EarnerServiceClient earnerService = null; try { UnPostedTimeSearchCriteria searchCriteria = new UnPostedTimeSearchCriteria(); searchCriteria.UserId = _logonSettings.DbUid; searchCriteria.TimeDate = DateTime.Now.Date; earnerService = new EarnerServiceClient(); EarnerReturnValue earnerReturnVal = earnerService.GetFeeEarnerReference(_logonSettings.LogonId, _logonSettings.MemberId); if (earnerReturnVal.Success) { searchCriteria.FeeEarnerRef = earnerReturnVal.EarnerRef; } else { throw new Exception(earnerReturnVal.Message); } CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.StartRow = _grdTodaysTimesheet.PageIndex * _grdTodaysTimesheet.PageSize; collectionRequest.RowCount = _grdTodaysTimesheet.PageSize; //Get unposted time entries timeService = new TimeServiceClient(); UnPostedTimeSearchReturnValue returnValue = timeService.UnPostedTimeSheetSearch(_logonSettings.LogonId, collectionRequest, searchCriteria); if (returnValue.UnPostedTimeSheet.Rows != null && returnValue.UnPostedTimeSheet.Rows.Length > 0) { foreach (GridViewRow row in _grdTodaysTimesheet.Rows) { CheckBox timeSheetSelected = (CheckBox)row.FindControl("_chkSelect"); int timeId = (int)_grdTodaysTimesheet.DataKeys[row.RowIndex].Values["TimeId"]; //Find the item in the collection UnPostedTimeSearchItem timeSheetItem = returnValue.UnPostedTimeSheet.Rows.First(time => time.TimeId == timeId); //Check if the item is selected if (timeSheetSelected.Checked) { //Validate the posting period PeriodCriteria criteria = new PeriodCriteria(); criteria.Date = timeSheetItem.TimeDate;//returnValue.UnPostedTimeSheet.Rows[0].TimeDate; criteria.IsTime = true; criteria.IsPostingVATable = false; criteria.IsAllowedPostBack2ClosedYear = false; PeriodDetailsReturnValue periodDetailsReturnValue = new PeriodDetailsReturnValue(); periodDetailsReturnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria); if (periodDetailsReturnValue.Success) { //Display warning mesg(if any) if (periodDetailsReturnValue.PeriodStatus == 3 && displayWarnings) { _mdlPopUpCofirmationBox.Show(); return; } if (periodDetailsReturnValue.PeriodStatus == 2) { throw new Exception(periodDetailsReturnValue.ErrorMessage); } if (timeSheetItem != null) { bool canBePosted = true; if (timeSheetItem.BillingTypeActive && timeSheetItem.BillingTypeArchived == false && timeSheetItem.TimeLAAsked == false) { canBePosted = false; } if (canBePosted) { TimeSheet timeSheet = new TimeSheet(); timeSheet.TimeId = timeSheetItem.TimeId; timeSheet.PeriodId = periodDetailsReturnValue.PeriodId; timeSheet.MemberId = timeSheetItem.MemberId.ToString(); timeSheet.CurrencyId = timeSheetItem.CurrencyId; timeSheet.PeriodMinutes = timeSheetItem.TimeElapsed; timeSheet.MasterPostedCost = timeSheetItem.TimeCost; timeSheet.MasterPostedCharge = timeSheetItem.TimeCharge; timeSheet.WorkingPostedCost = timeSheetItem.TimeCost; timeSheet.WorkingPostedCharge = timeSheetItem.TimeCharge; timeSheet.OrganisationId = timeSheetItem.OrganisationId; timeSheet.DepartmentId = timeSheetItem.DepartmentId; timeSheet.ProjectId = timeSheetItem.ProjectId; timeSheet.TimeTypeId = timeSheetItem.TimeTypeId; timeSheet.TimeDate = timeSheetItem.TimeDate; ReturnValue returnVal = timeService.PostTime(_logonSettings.LogonId, timeSheet); if (!returnVal.Success) { throw new Exception(returnVal.Message); } } } } else { throw new Exception(periodDetailsReturnValue.Message); } } } } } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) timeService.Close(); } if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) earnerService.Close(); } } }
private void BindFeeEarner() { EarnerServiceClient earnerService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); EarnerSearchCriteria criteria = new EarnerSearchCriteria(); criteria.IncludeArchived = false; criteria.MultiOnly = false; earnerService = new EarnerServiceClient(); EarnerSearchReturnValue returnValue = earnerService.EarnerSearch(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, collectionRequest, criteria); if (returnValue.Success) { _ddlFeeEarner.Items.Clear(); foreach (EarnerSearchItem feeEarner in returnValue.Earners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(feeEarner.Title, feeEarner.Name, feeEarner.SurName); item.Value = feeEarner.Reference + "$" + feeEarner.Id.ToString(); if (!_editMode) { if (((LogonReturnValue)Session[SessionName.LogonSettings]).MemberId == feeEarner.Id) { item.Selected = true; } } _ddlFeeEarner.Items.Add(item); } AddDefaultToDropDownList(_ddlFeeEarner); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) { earnerService.Close(); } } } }
private void BindPartner() { EarnerServiceClient earnerService = null; try { PartnerSearchCriteria criteria = new PartnerSearchCriteria(); earnerService = new EarnerServiceClient(); CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; collectionRequest.StartRow = 0; collectionRequest.RowCount = 0; PartnerSearchReturnValue returnValue = new PartnerSearchReturnValue(); returnValue = earnerService.PartnerSearch(_logonSettings.LogonId, collectionRequest, criteria); if (returnValue.Success) { foreach (PartnerSearchItem partner in returnValue.Partners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(partner.PersonTitle, partner.Name, partner.Surname); item.Value = partner.PartnerId.ToString(); _ddlPartner.Items.Add(item); } _ddlPartner.Items.Insert(0, new ListItem("All Partners", "")); } else { throw new Exception(returnValue.Message); } } catch (System.ServiceModel.EndpointNotFoundException) { _lblMessage.Text = DataConstants.WSEndPointErrorMessage; _lblMessage.CssClass = "errorMessage"; } catch (Exception ex) { _lblMessage.CssClass = "errorMessage"; _lblMessage.Text = ex.Message; } finally { if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) { earnerService.Close(); } } } }
/// <summary> /// Gets the fee earners. /// </summary> private void GetFeeEarners() { EarnerServiceClient earnerService = null; try { earnerService = new EarnerServiceClient(); PartnerSearchCriteria criteria = new PartnerSearchCriteria(); CollectionRequest collectionRequest = new CollectionRequest(); PartnerSearchReturnValue returnValue = new PartnerSearchReturnValue(); returnValue = earnerService.PartnerSearch(_logonId, collectionRequest, criteria); if (returnValue.Success) { _ddlFeeEarner.Items.Clear(); foreach (PartnerSearchItem partner in returnValue.Partners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(partner.PersonTitle, partner.Name, partner.Surname); item.Value = partner.PartnerId.ToString(); _ddlFeeEarner.Items.Add(item); } _ddlFeeEarner.Items.Insert(0, new ListItem("All Partners", "")); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) { earnerService.Close(); } } } }
/// <summary> /// Binds fee earners /// </summary> private void BindFeeEarner() { EarnerServiceClient earnerService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); EarnerSearchCriteria criteria = new EarnerSearchCriteria(); criteria.IncludeArchived = false; criteria.MultiOnly = false; earnerService = new EarnerServiceClient(); EarnerSearchReturnValue returnValue = earnerService.EarnerSearch(_logonSettings.LogonId, collectionRequest, criteria); if (returnValue.Success) { _ddlFeeEarner.Items.Clear(); foreach (EarnerSearchItem feeEarner in returnValue.Earners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(feeEarner.Title, feeEarner.Name, feeEarner.SurName); item.Value = feeEarner.Id.ToString(); _ddlFeeEarner.Items.Add(item); } } else { throw new Exception(returnValue.Message); } AppFunctions.AddDefaultToDropDownList(_ddlFeeEarner); } catch (Exception ex) { throw ex; } finally { if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) earnerService.Close(); } } }
private void LoadMatterFeeEarner(Guid ProjectID) { MatterServiceClient matterService = new MatterServiceClient(); try { MatterReturnValue matterReturnValue = new MatterReturnValue(); matterReturnValue = matterService.GetMatter(_logonSettings.LogonId, ProjectID); if (matterReturnValue.Success) { if (matterReturnValue != null) { if (matterReturnValue.Matter.FeeEarnerMemberId != null) { EarnerServiceClient partnerClient = new EarnerServiceClient(); try { PartnerSearchCriteria partnerCriteria = new PartnerSearchCriteria(); CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.StartRow = 0; PartnerSearchReturnValue partnerReturnValue = partnerClient.PartnerSearch(_logonSettings.LogonId, collectionRequest, partnerCriteria); if (partnerReturnValue.Success) { if (partnerReturnValue.Partners != null) { for (int i = 0; i < partnerReturnValue.Partners.Rows.Length; i++) { if (partnerReturnValue.Partners.Rows[i].PartnerId.ToString() == matterReturnValue.Matter.FeeEarnerMemberId.ToString()) { _txtAttendees.Text = CommonFunctions.MakeFullName(partnerReturnValue.Partners.Rows[i].PersonTitle, partnerReturnValue.Partners.Rows[i].Name, partnerReturnValue.Partners.Rows[i].Surname); _hdnAttendeesMemberId.Value = partnerReturnValue.Partners.Rows[i].PartnerId.ToString() + ";"; } } } } else { _lblError.Text = partnerReturnValue.Message; } } catch (Exception ex) { throw ex; } finally { if (partnerClient.State != System.ServiceModel.CommunicationState.Faulted) partnerClient.Close(); } } } } } catch (Exception ex) { throw ex; } finally { if (matterService.State != System.ServiceModel.CommunicationState.Faulted) matterService.Close(); } }
private void BindPartner() { EarnerServiceClient earnerService = null; try { PartnerSearchCriteria criteria = new PartnerSearchCriteria(); earnerService = new EarnerServiceClient(); CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; collectionRequest.StartRow = 0; collectionRequest.RowCount = 0; PartnerSearchReturnValue returnValue = new PartnerSearchReturnValue(); returnValue = earnerService.PartnerSearch(_logonSettings.LogonId, collectionRequest, criteria); if (returnValue.Success) { foreach (PartnerSearchItem partner in returnValue.Partners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(partner.PersonTitle, partner.Name, partner.Surname); item.Value = partner.PartnerId.ToString(); _ddlPartner.Items.Add(item); } _ddlPartner.Items.Insert(0, new ListItem("All Partners", "")); } else { throw new Exception(returnValue.Message); } } catch (System.ServiceModel.EndpointNotFoundException) { _lblMessage.Text = DataConstants.WSEndPointErrorMessage; _lblMessage.CssClass = "errorMessage"; } catch (Exception ex) { _lblMessage.CssClass = "errorMessage"; _lblMessage.Text = ex.Message; } finally { if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) earnerService.Close(); } } }
/// <summary> /// Gets the fee earners. /// </summary> private void GetFeeEarners() { EarnerServiceClient earnerService = null; try { earnerService = new EarnerServiceClient(); PartnerSearchCriteria criteria = new PartnerSearchCriteria(); CollectionRequest collectionRequest = new CollectionRequest(); PartnerSearchReturnValue returnValue = new PartnerSearchReturnValue(); returnValue = earnerService.PartnerSearch(_logonId, collectionRequest, criteria); if (returnValue.Success) { _ddlFeeEarner.Items.Clear(); foreach (PartnerSearchItem partner in returnValue.Partners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(partner.PersonTitle, partner.Name, partner.Surname); item.Value = partner.PartnerId.ToString(); _ddlFeeEarner.Items.Add(item); } _ddlFeeEarner.Items.Insert(0, new ListItem("All Partners", "")); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) earnerService.Close(); } } }
/// <summary> /// This method will post the selected timesheet entries for accounting /// </summary> /// <param name="displayWarnings">if set to <c>true</c> display warnings.</param> private void PostTime(bool displayWarnings) { TimeServiceClient timeService = null; EarnerServiceClient earnerService = null; try { UnPostedTimeSearchCriteria searchCriteria = new UnPostedTimeSearchCriteria(); searchCriteria.UserId = _logonSettings.DbUid; searchCriteria.TimeDate = DateTime.Now.Date; earnerService = new EarnerServiceClient(); EarnerReturnValue earnerReturnVal = earnerService.GetFeeEarnerReference(_logonSettings.LogonId, _logonSettings.MemberId); if (earnerReturnVal.Success) { searchCriteria.FeeEarnerRef = earnerReturnVal.EarnerRef; } else { throw new Exception(earnerReturnVal.Message); } CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.StartRow = _grdTodaysTimesheet.PageIndex * _grdTodaysTimesheet.PageSize; collectionRequest.RowCount = _grdTodaysTimesheet.PageSize; //Get unposted time entries timeService = new TimeServiceClient(); UnPostedTimeSearchReturnValue returnValue = timeService.UnPostedTimeSheetSearch(_logonSettings.LogonId, collectionRequest, searchCriteria); if (returnValue.UnPostedTimeSheet.Rows != null && returnValue.UnPostedTimeSheet.Rows.Length > 0) { foreach (GridViewRow row in _grdTodaysTimesheet.Rows) { CheckBox timeSheetSelected = (CheckBox)row.FindControl("_chkSelect"); int timeId = (int)_grdTodaysTimesheet.DataKeys[row.RowIndex].Values["TimeId"]; //Find the item in the collection UnPostedTimeSearchItem timeSheetItem = returnValue.UnPostedTimeSheet.Rows.First(time => time.TimeId == timeId); //Check if the item is selected if (timeSheetSelected.Checked) { //Validate the posting period PeriodCriteria criteria = new PeriodCriteria(); criteria.Date = timeSheetItem.TimeDate;//returnValue.UnPostedTimeSheet.Rows[0].TimeDate; criteria.IsTime = true; criteria.IsPostingVATable = false; criteria.IsAllowedPostBack2ClosedYear = false; PeriodDetailsReturnValue periodDetailsReturnValue = new PeriodDetailsReturnValue(); periodDetailsReturnValue = timeService.ValidatePeriod(_logonSettings.LogonId, criteria); if (periodDetailsReturnValue.Success) { //Display warning mesg(if any) if (periodDetailsReturnValue.PeriodStatus == 3 && displayWarnings) { _mdlPopUpCofirmationBox.Show(); return; } if (periodDetailsReturnValue.PeriodStatus == 2) { throw new Exception(periodDetailsReturnValue.ErrorMessage); } if (timeSheetItem != null) { bool canBePosted = true; if (timeSheetItem.BillingTypeActive && timeSheetItem.BillingTypeArchived == false && timeSheetItem.TimeLAAsked == false) { canBePosted = false; } if (canBePosted) { TimeSheet timeSheet = new TimeSheet(); timeSheet.TimeId = timeSheetItem.TimeId; timeSheet.PeriodId = periodDetailsReturnValue.PeriodId; timeSheet.MemberId = timeSheetItem.MemberId.ToString(); timeSheet.CurrencyId = timeSheetItem.CurrencyId; timeSheet.PeriodMinutes = timeSheetItem.TimeElapsed; timeSheet.MasterPostedCost = timeSheetItem.TimeCost; timeSheet.MasterPostedCharge = timeSheetItem.TimeCharge; timeSheet.WorkingPostedCost = timeSheetItem.TimeCost; timeSheet.WorkingPostedCharge = timeSheetItem.TimeCharge; timeSheet.OrganisationId = timeSheetItem.OrganisationId; timeSheet.DepartmentId = timeSheetItem.DepartmentId; timeSheet.ProjectId = timeSheetItem.ProjectId; timeSheet.TimeTypeId = timeSheetItem.TimeTypeId; timeSheet.TimeDate = timeSheetItem.TimeDate; ReturnValue returnVal = timeService.PostTime(_logonSettings.LogonId, timeSheet); if (!returnVal.Success) { throw new Exception(returnVal.Message); } } } } else { throw new Exception(periodDetailsReturnValue.Message); } } } } } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) { timeService.Close(); } } if (earnerService != null) { if (earnerService.State != System.ServiceModel.CommunicationState.Faulted) { earnerService.Close(); } } } }
private void BindFeeEarner() { EarnerServiceClient earnerService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); EarnerSearchCriteria criteria = new EarnerSearchCriteria(); criteria.IncludeArchived = false; criteria.MultiOnly = false; earnerService = new EarnerServiceClient(); EarnerSearchReturnValue returnValue = earnerService.EarnerSearch(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, collectionRequest, criteria); if (returnValue.Success) { _ddlFeeEarner.Items.Clear(); foreach (EarnerSearchItem feeEarner in returnValue.Earners.Rows) { ListItem item = new ListItem(); item.Text = CommonFunctions.MakeFullName(feeEarner.Title, feeEarner.Name, feeEarner.SurName); item.Value = feeEarner.Reference + "$" + feeEarner.Id.ToString(); if (!_editMode) { if (((LogonReturnValue)Session[SessionName.LogonSettings]).MemberId == feeEarner.Id) { item.Selected = true; } } _ddlFeeEarner.Items.Add(item); } AddDefaultToDropDownList(_ddlFeeEarner); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (earnerService != null) { earnerService.Close(); } } }
private void LoadMatterFeeEarner(Guid ProjectID) { MatterServiceClient matterService = new MatterServiceClient(); try { MatterReturnValue matterReturnValue = new MatterReturnValue(); matterReturnValue = matterService.GetMatter(_logonSettings.LogonId, ProjectID); if (matterReturnValue.Success) { if (matterReturnValue != null) { if (matterReturnValue.Matter.FeeEarnerMemberId != null) { EarnerServiceClient partnerClient = new EarnerServiceClient(); try { PartnerSearchCriteria partnerCriteria = new PartnerSearchCriteria(); CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.StartRow = 0; PartnerSearchReturnValue partnerReturnValue = partnerClient.PartnerSearch(_logonSettings.LogonId, collectionRequest, partnerCriteria); if (partnerReturnValue.Success) { if (partnerReturnValue.Partners != null) { for (int i = 0; i < partnerReturnValue.Partners.Rows.Length; i++) { if (partnerReturnValue.Partners.Rows[i].PartnerId.ToString() == matterReturnValue.Matter.FeeEarnerMemberId.ToString()) { _txtAttendees.Text = CommonFunctions.MakeFullName(partnerReturnValue.Partners.Rows[i].PersonTitle, partnerReturnValue.Partners.Rows[i].Name, partnerReturnValue.Partners.Rows[i].Surname); _hdnAttendeesMemberId.Value = partnerReturnValue.Partners.Rows[i].PartnerId.ToString() + ";"; } } } } else { _lblError.Text = partnerReturnValue.Message; } } catch (Exception ex) { throw ex; } finally { if (partnerClient.State != System.ServiceModel.CommunicationState.Faulted) { partnerClient.Close(); } } } } } } catch (Exception ex) { throw ex; } finally { if (matterService.State != System.ServiceModel.CommunicationState.Faulted) { matterService.Close(); } } }