/// <summary> /// Binds VAT rates on page load /// </summary> private void BindVATRates() { _ddlVATRate.Items.Clear(); AccountsServiceClient vatRateClient = new AccountsServiceClient(); try { VatRateSearchCriteria criteria = new VatRateSearchCriteria(); criteria.IncludeNonVatable = false; criteria.IncludeArchived = false; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.StartRow = 0; VatRateSearchReturnValue vatReturnValue = vatRateClient.VatRateSearch(_logonSettings.LogonId, collectionRequest, criteria); if (vatReturnValue.Success) { if (vatReturnValue.VatRates != null) { for (int i = 0; i < vatReturnValue.VatRates.Rows.Length; i++) { ListItem item = new ListItem(vatReturnValue.VatRates.Rows[i].Description, vatReturnValue.VatRates.Rows[i].Id.ToString() + "$" + vatReturnValue.VatRates.Rows[i].Percentage.ToString()); if (vatReturnValue.VatRates.Rows[i].IsDefault) { _ddlVATRate.SelectedIndex = -1; item.Selected = true; } _ddlVATRate.Items.Add(item); } } } else { _lblMessage.Text = vatReturnValue.Message; } } catch (System.ServiceModel.EndpointNotFoundException) { _lblMessage.Text = DataConstants.WSEndPointErrorMessage; _lblMessage.CssClass = "errorMessage"; } catch (Exception ex) { _lblMessage.CssClass = "errorMessage"; _lblMessage.Text = ex.Message; } finally { if (vatRateClient.State != System.ServiceModel.CommunicationState.Faulted) { vatRateClient.Close(); } } }
public VatRateSearchReturnValue VatRateSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, VatRateSearchCriteria criteria) { VatRateSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.VatRateSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new VatRateSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
public VatRateSearchReturnValue VatRateSearch(Guid logonId, CollectionRequest collectionRequest, VatRateSearchCriteria criteria) { VatRateSearchReturnValue returnValue = new VatRateSearchReturnValue(); 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"); } // Create a data list creator for a list of ratings DataListCreator<VatRateSearchItem> dataListCreator = new DataListCreator<VatRateSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvVATRateLookup.GetAllVatRates(criteria.IncludeNonVatable, criteria.IncludeArchived); }; // Create the data list returnValue.VatRates = dataListCreator.Create(logonId, // Give the query a name so it can be cached "VatRateSearch", // Tell it the query criteria used so if the cache is accessed // again it knows if it is the same query criteria.ToString(), collectionRequest, // Import mappings to map the dataset row fields to the data // list entity properties new ImportMapping[] { new ImportMapping("Id", "VatRateId"), new ImportMapping("Description", "VatRateDescription"), new ImportMapping("IsDefault", "VatRateDefault"), new ImportMapping("Percentage", "VatRatePercentage") } ); } 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; }
public VatRateSearchReturnValue VatRateSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, VatRateSearchCriteria criteria) { VatRateSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.VatRateSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new VatRateSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }