/// <summary> /// Get one matter /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="projectId">Matter project id</param> /// <returns></returns> public MatterReturnValue GetMatter(Guid logonId, Guid projectId) { MatterReturnValue returnValue = new MatterReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. // ApplicationSettings.Instance can now be used to get the // ApplicationSettings for this session. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: if (!SrvMatterCommon.WebAllowedToAccessMatter(projectId)) throw new Exception("Access denied"); break; default: throw new Exception("Access denied"); } SrvMatter srvMatter = new SrvMatter(); int campaignId = SrvMatterCommon.GetCampaignForProject(projectId); srvMatter.Load(projectId); Matter matter = new Matter(); matter.Id = srvMatter.ProjectId; // Load Matter Details matter.Description = srvMatter.MatterDescription; matter.KeyDescription = srvMatter.MatterKeyDescription; matter.FeeEarnerMemberId = srvMatter.FeeEarnerMemberId; matter.PartnerMemberId = srvMatter.MatterPartnerMemberId; matter.WorkTypeId = srvMatter.CurrentWorkTypeId; matter.ClientBankId = srvMatter.ClientBankId; matter.OfficeBankId = srvMatter.OfficeBankId; matter.DepositBankId = srvMatter.MatterDepositBankId; matter.BranchReference = srvMatter.BranchId; matter.DepartmentId = srvMatter.DepartmentId; matter.ChargeDescriptionId = srvMatter.ChargeDescriptionId; matter.CourtId = srvMatter.CourtId; matter.OpenDate = srvMatter.MatterOpenDate; matter.NextReviewDate = srvMatter.MatterNextReviewDate; matter.CostReviewDate = srvMatter.MatterCostReviewDate; matter.LastSavedDate = srvMatter.MatterLastSaved; matter.ClosedDate = srvMatter.MatterClosedDate; matter.DestructDate = srvMatter.MatterDestructDate; matter.FileNo = srvMatter.MatterFileNo; matter.CompletedDate = srvMatter.MatterCompleted; matter.SpanType1Ref = srvMatter.SpanType1; matter.SpanType2Ref = srvMatter.SpanType2; // Load Matter Additional Info matter.Quote = srvMatter.MatterQuote; matter.DisbsLimit = srvMatter.MatterDisbsLimit; matter.TimeLimit = srvMatter.MatterTimeLimit; matter.WIPLimit = srvMatter.MatterWIPLimit; matter.OverallLimit = srvMatter.MatterOverallLimit; matter.Status = srvMatter.MatterStatus; matter.Indicators = srvMatter.MatterIndicators; matter.BankReference = srvMatter.MatterBankReference; matter.CashCollectionId = srvMatter.MatCashCollID; matter.TotalLockup = srvMatter.MatTotalLockup; matter.OurReference = srvMatter.OurReference; matter.PreviousReference = srvMatter.PreviousReference; matter.BusinessSourceId = srvMatter.SourceID; matter.SourceCampaignId = campaignId; matter.PersonDealingId = srvMatter.UserId; matter.SalutationEnvelope = srvMatter.MatterSalutationEnvelope; matter.SalutationLetter = srvMatter.MatterSalutationLetter; matter.LetterHead = srvMatter.MatterLetterHead; // Load Public Funding matter.MatterLegalAided = srvMatter.MatterLegalAided; matter.IsPublicFunding = srvMatter.IsPublicFunding; matter.Franchised = srvMatter.MatterFranchised; matter.isLondonRate = srvMatter.MatterLondonRate; matter.UFNDate = srvMatter.UFNDate; matter.UFN = srvMatter.UFNNumber; matter.PFCertificateNo = srvMatter.MatterPFCertificateNo; matter.PFCertificateNoLimits = srvMatter.MatterPFCertificateLimits; matter.MatterTypeId = srvMatter.MatterTypeId; // Load Client Details Client client = new Client(); client.IsMember = srvMatter.IsMember; //Set MemberID for Individual if (client.IsMember) { client.MemberId = srvMatter.ClientId; client.OrganisationId = DataConstants.DummyGuid; } //Set OrganisationId for Organisation else { client.MemberId = DataConstants.DummyGuid; client.OrganisationId = srvMatter.ClientId; } client.Reference = srvMatter.ClientReference; client.FullName = srvMatter.ClientName; client.IsArchived = srvMatter.IsClientArchived; // Get Client Type ID client.TypeId = this.GetClientType(srvMatter.ClientId, srvMatter.ProjectId, srvMatter.IsMember); returnValue.Matter = matter; returnValue.ClientDetails = client; } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }
/// <summary> /// Loads office cheque request details for printing /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="clientChequeRequestId">Office cheque request id toget cheque request details.</param> /// <returns>Returns office cheque request details by office cheque request id.</returns> public ChequeRequestReturnValue LoadOfficeChequeRequestDetailsForPrinting(Guid logonId, int officeChequeRequestId) { ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } ChequeRequest officeChequeRequest = new ChequeRequest(); DsOfficeChequeRequests dsOfficeChequeRequestsDetails = SrvOfficeChequeRequestLookup.GetOfficeChequeRequestsByOfficeChequeRequestId(officeChequeRequestId); // Gets printable properties from the dataset foreach (DataRow drOfficeChequeRequest in dsOfficeChequeRequestsDetails.OfficeChequeRequests.Rows) { Guid projectId = (Guid)drOfficeChequeRequest["projectId"]; // Gets the matter description by project id SrvMatter srvMatter = new SrvMatter(); srvMatter.Load(projectId); Guid clientId = srvMatter.ClientId; string matterDescription = srvMatter.MatterDescription; string matterReference = srvMatter.MatterReference; bool isMember = srvMatter.IsMember; // Inserts "-" in between matter reference matterReference = matterReference.Insert(6, "-"); string personName = srvMatter.ClientName; // Gets the partner name by partner member id for project id Guid partnerId = srvMatter.MatterPartnerMemberId; string partnerName = SrvEarnerCommon.GetFeeEarnerNameByFeeEarnerId(partnerId); // Gets the fee earner name by fee earner id Guid feeEarnerId = srvMatter.FeeEarnerMemberId; string feeEarnerName = SrvEarnerCommon.GetFeeEarnerNameByFeeEarnerId(feeEarnerId); // This member id is from application settings for accounts. Guid userMemberId = (Guid)drOfficeChequeRequest["memberId"]; DateTime officeChequeRequestDate = (DateTime)drOfficeChequeRequest["OfficeChequeRequestsDate"]; // Gets user name by member id DsSystemUsers dsSystemUsers = SrvUserLookup.GetUser(userMemberId.ToString()); string userName = string.Empty; if (dsSystemUsers.uvw_SystemUsers.Count > 0) { userName = dsSystemUsers.uvw_SystemUsers[0].name; } else { DsPersonDealing dsPersonDealing = SrvMatterLookup.GetPersonDealingLookup(); for (int index = 0; index < dsPersonDealing.uvw_PersonDealingLookup.Count; index++) { if (dsPersonDealing.uvw_PersonDealingLookup[index].MemberID == userMemberId) { userName = dsPersonDealing.uvw_PersonDealingLookup[index].name; } } } int bankId = (int)drOfficeChequeRequest["bankId"]; string officeChequeRequestDescription = (string)drOfficeChequeRequest["OfficeChequeRequestsDesc"]; string officeChequeRequestPayee = (string)drOfficeChequeRequest["OfficeChequeRequestsPayee"]; int officeChequeRequestVATRateId = (int)drOfficeChequeRequest["VatRateId"]; // Gets VAT rate by VAT rate id DsVatRates dsVATRates = SrvVATRateLookup.GetVatRates(officeChequeRequestVATRateId); string officeChequeRequestVATRateReference = (string)dsVATRates.VatRates[0].VatRateRef; // Gets the bank name by bank id string officeChequeRequestBankName = this.GetBankByBankId(bankId); decimal officeChequeRequestAmount = (decimal)drOfficeChequeRequest["OfficeChequeRequestsAmount"]; decimal officeChequeRequestVATAmount = (decimal)drOfficeChequeRequest["OfficeChequeRequestsVATAmount"]; bool isOfficeChequeAuthorised = (bool)drOfficeChequeRequest["OfficeChequeRequestsIsAuthorised"]; bool isOfficeChequeAnticipated = (bool)drOfficeChequeRequest["OfficeChequeRequestIsAnticipated"]; officeChequeRequest.UserName = userName; officeChequeRequest.PersonName = personName; officeChequeRequest.PartnerName = partnerName; officeChequeRequest.FeeEarnerReference = feeEarnerName; officeChequeRequest.BankName = officeChequeRequestBankName; officeChequeRequest.ChequeRequestDate = officeChequeRequestDate; officeChequeRequest.ChequeRequestPayee = officeChequeRequestPayee; officeChequeRequest.VATAmount = officeChequeRequestVATAmount; officeChequeRequest.VATRate = officeChequeRequestVATRateReference; officeChequeRequest.ChequeRequestAmount = officeChequeRequestAmount; officeChequeRequest.MatterDescription = matterDescription; officeChequeRequest.MatterReference = matterReference; officeChequeRequest.IsChequeRequestAuthorised = isOfficeChequeAuthorised; officeChequeRequest.IsChequeRequestAnticipated = isOfficeChequeAnticipated; officeChequeRequest.ChequeRequestDescription = officeChequeRequestDescription; // Gets addressline1,addressline2,addressline3 for client. if (isMember) { DsMemAddress dsMemAddress = SrvAddressLookup.GetMemberAddresses(clientId); if (dsMemAddress.Address.Rows.Count > 0) { officeChequeRequest.AddressLine1 = dsMemAddress.Address[0].AddressLine1.ToString().Trim(); officeChequeRequest.AddressLine2 = dsMemAddress.Address[0].AddressLine2.ToString().Trim(); officeChequeRequest.AddressLine3 = dsMemAddress.Address[0].AddressLine3.ToString().Trim(); officeChequeRequest.AddressTown = dsMemAddress.Address[0].AddressTown.ToString().Trim(); officeChequeRequest.AddressCounty = dsMemAddress.Address[0].AddressCounty.ToString().Trim(); officeChequeRequest.AddressPostcode = dsMemAddress.Address[0].AddressPostCode.ToString().Trim(); } } else // Look for organisation address if the client is not member. { DsOrgAddress dsOrgAddress = SrvAddressLookup.GetOrganisationAddresses(clientId); if (dsOrgAddress.Address.Rows.Count > 0) { officeChequeRequest.AddressLine1 = dsOrgAddress.Address[0].AddressLine1.ToString().Trim(); officeChequeRequest.AddressLine2 = dsOrgAddress.Address[0].AddressLine2.ToString().Trim(); officeChequeRequest.AddressLine3 = dsOrgAddress.Address[0].AddressLine3.ToString().Trim(); officeChequeRequest.AddressTown = dsOrgAddress.Address[0].AddressTown.ToString().Trim(); officeChequeRequest.AddressCounty = dsOrgAddress.Address[0].AddressCounty.ToString().Trim(); officeChequeRequest.AddressPostcode = dsOrgAddress.Address[0].AddressPostCode.ToString().Trim(); } } } returnValue.ChequeRequest = officeChequeRequest; } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }
/// <summary> /// Update an existing matter /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="matter">Matter details</param> /// <returns></returns> public ReturnValue UpdateMatter(Guid logonId, Matter matter) { ReturnValue returnValue = new ReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } SrvMatter srvMatter = new SrvMatter(); srvMatter.Load(matter.Id); // Save Matter Details srvMatter.ProjectId = matter.Id; srvMatter.MatterDescription = matter.Description; srvMatter.MatterKeyDescription = matter.KeyDescription; srvMatter.FeeEarnerMemberId = matter.FeeEarnerMemberId; srvMatter.MatterPartnerMemberId = matter.PartnerMemberId; srvMatter.CurrentWorkTypeId = matter.WorkTypeId; srvMatter.ClientBankId = matter.ClientBankId; srvMatter.OfficeBankId = matter.OfficeBankId; srvMatter.MatterDepositBankId = matter.DepositBankId; srvMatter.BranchId = matter.BranchReference; srvMatter.DepartmentId = matter.DepartmentId; srvMatter.ChargeDescriptionId = matter.ChargeDescriptionId; srvMatter.CourtId = matter.CourtId; srvMatter.MatterOpenDate = matter.OpenDate; srvMatter.MatterNextReviewDate = matter.NextReviewDate; srvMatter.MatterCostReviewDate = matter.CostReviewDate; srvMatter.MatterClosedDate = matter.ClosedDate; srvMatter.MatterDestructDate = matter.DestructDate; srvMatter.MatterFileNo = matter.FileNo; srvMatter.MatterCompleted = matter.CompletedDate; // Save Matter Additional Info srvMatter.MatterQuote = matter.Quote; srvMatter.MatterDisbsLimit = matter.DisbsLimit; srvMatter.MatterTimeLimit = matter.TimeLimit; srvMatter.MatterWIPLimit = matter.WIPLimit; srvMatter.MatterOverallLimit = matter.OverallLimit; srvMatter.MatterStatus = matter.Status; srvMatter.MatterIndicators = matter.Indicators; srvMatter.MatterBankReference = matter.BankReference; srvMatter.MatCashCollID = matter.CashCollectionId; srvMatter.MatTotalLockup = matter.TotalLockup; srvMatter.OurReference = matter.OurReference; srvMatter.PreviousReference = matter.PreviousReference; srvMatter.SourceID = matter.BusinessSourceId; // TODO: Save Campaign Id // = campaignId = matter.SourceCampaignId; srvMatter.UserId = matter.PersonDealingId; srvMatter.MatterSalutationEnvelope = matter.SalutationEnvelope; srvMatter.MatterSalutationLetter = matter.SalutationLetter; srvMatter.MatterLetterHead = matter.LetterHead; //Save Matter Public Funding srvMatter.MatterLegalAided = matter.IsPublicFunding; srvMatter.MatterFranchised = matter.Franchised; srvMatter.MatterLondonRate = matter.isLondonRate; srvMatter.UFNDate = matter.UFNDate; srvMatter.UFNNumber = matter.UFN; srvMatter.MatterPFCertificateNo = matter.PFCertificateNo; srvMatter.MatterPFCertificateLimits = matter.PFCertificateNoLimits; srvMatter.MatterTypeId = matter.MatterTypeId; srvMatter.ClientId = matter.ClientId; string errorMessage; returnValue.Success = srvMatter.Save(out errorMessage); returnValue.Message = errorMessage; } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }
/// <summary> /// Loads cheque request details /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="clientChequeRequestId">Client cheque request id toget cheque request details.</param> /// <returns>Returns client cheque request details by client cheque request id.</returns> public ChequeRequestReturnValue LoadClientChequeRequestDetailsForPrinting(Guid logonId, int clientChequeRequestId) { ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } ChequeRequest clientChequeRequest = new ChequeRequest(); DsClientChequeRequestsDetails dsClientChequeRequestsDetails = SrvClientChequeRequestLookup.GetClientChequeRequestDetails(clientChequeRequestId); // Gets printable properties from the dataset foreach (DataRow drClientChequeRequest in dsClientChequeRequestsDetails.uvw_ClientChequeRequestsDetails.Rows) { Guid projectId = (Guid)drClientChequeRequest["projectId"]; // Gets the matter details by project id SrvMatter srvMatter = new SrvMatter(); srvMatter.Load(projectId); Guid clientId = srvMatter.ClientId; bool isMember = srvMatter.IsMember; string matterDescription = srvMatter.MatterDescription; string matterReference = srvMatter.MatterReference; // Inserts "-" in between matter reference matterReference = matterReference.Insert(6, "-"); string personName = srvMatter.ClientName; // Gets the partner name by partner member id for project id Guid partnerId = srvMatter.MatterPartnerMemberId; string partnerName = SrvEarnerCommon.GetFeeEarnerNameByFeeEarnerId(partnerId); // Client name should be related to project id DateTime clientChequeRequestDate = (DateTime)drClientChequeRequest["ClientChequeRequestsDate"]; string feeEarnerReference = (string)drClientChequeRequest["feeRef"]; string userName = (string)drClientChequeRequest["userName"]; string clientChequeRequestDescription = (string)drClientChequeRequest["ClientChequeRequestsDesc"]; string clientChequeRequestPayee = (string)drClientChequeRequest["ClientChequeRequestsPayee"]; int bankId = (int)drClientChequeRequest["bankId"]; string clientChequeRequestBankName = this.GetBankByBankId(bankId); decimal clientChequeRequestAmount = (decimal)drClientChequeRequest["ClientChequeRequestsAmount"]; bool isClientChequeAuthorised = (bool)drClientChequeRequest["ClientChequeRequestsIsAuthorised"]; string matBranchRef = (string)drClientChequeRequest["matBranchRef"]; string ClearanceTypeDesc = (string)drClientChequeRequest["ClearanceTypeDesc"]; clientChequeRequest.PersonName = personName; clientChequeRequest.IsChequeRequestAuthorised = isClientChequeAuthorised; clientChequeRequest.ChequeRequestDate = clientChequeRequestDate; clientChequeRequest.ChequeRequestDescription = clientChequeRequestDescription; clientChequeRequest.ChequeRequestPayee = clientChequeRequestPayee; clientChequeRequest.BankName = clientChequeRequestBankName; clientChequeRequest.ChequeRequestAmount = clientChequeRequestAmount; clientChequeRequest.UserName = userName; clientChequeRequest.FeeEarnerReference = feeEarnerReference; clientChequeRequest.MatterReference = matterReference; clientChequeRequest.MatterDescription = matterDescription; clientChequeRequest.PartnerName = partnerName; clientChequeRequest.ClearanceTypeDesc = ClearanceTypeDesc; clientChequeRequest.MatBranchRef = matBranchRef; // Gets address details for client if (isMember) { DsMemAddress dsMemAddress = SrvAddressLookup.GetMemberAddresses(clientId); if (dsMemAddress.Address.Rows.Count > 0) { clientChequeRequest.AddressLine1 = dsMemAddress.Address[0].AddressLine1.ToString().Trim(); clientChequeRequest.AddressLine2 = dsMemAddress.Address[0].AddressLine2.ToString().Trim(); clientChequeRequest.AddressLine3 = dsMemAddress.Address[0].AddressLine3.ToString().Trim(); clientChequeRequest.AddressTown = dsMemAddress.Address[0].AddressTown.ToString().Trim(); clientChequeRequest.AddressCounty = dsMemAddress.Address[0].AddressCounty.ToString().Trim(); clientChequeRequest.AddressPostcode = dsMemAddress.Address[0].AddressPostCode.ToString().Trim(); } } else // if a client is not member client look address detail fo organisation client. { DsOrgAddress dsOrgAddress = SrvAddressLookup.GetOrganisationAddresses(clientId); if (dsOrgAddress.Address.Rows.Count > 0) { clientChequeRequest.AddressLine1 = dsOrgAddress.Address[0].AddressLine1.ToString().Trim(); clientChequeRequest.AddressLine2 = dsOrgAddress.Address[0].AddressLine2.ToString().Trim(); clientChequeRequest.AddressLine3 = dsOrgAddress.Address[0].AddressLine3.ToString().Trim(); clientChequeRequest.AddressTown = dsOrgAddress.Address[0].AddressTown.ToString().Trim(); clientChequeRequest.AddressCounty = dsOrgAddress.Address[0].AddressCounty.ToString().Trim(); clientChequeRequest.AddressPostcode = dsOrgAddress.Address[0].AddressPostCode.ToString().Trim(); } } } returnValue.ChequeRequest = clientChequeRequest; } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }