/// <summary> /// Loads the by customer and order group id. /// </summary> /// <param name="CustomerId">The customer id.</param> /// <param name="OrderGroupId">The order group id.</param> /// <returns></returns> public static PurchaseOrder LoadByCustomerAndOrderGroupId(Guid CustomerId, int OrderGroupId) { Guid searchGuid = Guid.NewGuid(); DataCommand cmd = OrderDataHelper.CreateTranDataCommand(); cmd.CommandText = String.Format("ecf_Search_{0}_CustomerAndOrderGroupId", OrderContext.Current.PurchaseOrderMetaClass.Name); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("SearchSetId", searchGuid, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("CustomerId", CustomerId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("OrderGroupId", OrderGroupId, DataParameterType.Int)); // Might be good idea to signal if there are results at all DataService.Run(cmd); // Load results and return them back MetaStorageCollectionBase <PurchaseOrder> orders = LoadSearchResults(searchGuid); if (orders.Count > 0) { return(orders[0]); } return(null); }
/// <summary> /// Loads cat by name and customer id. /// </summary> /// <param name="CustomerId">The customer id.</param> /// <param name="Name">The name.</param> /// <returns></returns> public static Cart LoadByCustomerAndName(Guid CustomerId, string Name) { Guid searchGuid = Guid.NewGuid(); DataCommand cmd = OrderDataHelper.CreateTranDataCommand(); cmd.CommandText = String.Format("ecf_Search_{0}_CustomerAndName", OrderContext.Current.ShoppingCartMetaClass.Name); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("SearchSetId", searchGuid, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("CustomerId", CustomerId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("Name", Name, DataParameterType.NVarChar)); cmd.Parameters[2].Size = 64; // Might be good idea to signal if there are results at all DataService.Run(cmd); // Load results and return them back MetaStorageCollectionBase <Cart> carts = LoadSearchResults(searchGuid); if (carts.Count > 0) { return(carts[0]); } return(null); }
/// <summary> /// Loads the search results. /// </summary> /// <param name="SearchGuid">The search GUID.</param> /// <returns></returns> private static MetaStorageCollectionBase <PurchaseOrder> LoadSearchResults(Guid SearchGuid) { DataCommand cmd = OrderDataHelper.CreateTranDataCommand(); cmd.CommandText = String.Format("ecf_Search_{0}", OrderContext.Current.PurchaseOrderMetaClass.Name); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("SearchSetId", SearchGuid, DataParameterType.UniqueIdentifier)); // Might be good idea to signal if there are results at all DataResult result = DataService.LoadDataSet(cmd); MetaStorageCollectionBase <PurchaseOrder> orders = new MetaStorageCollectionBase <PurchaseOrder>(); PopulateCollection <PurchaseOrder>(OrderContext.Current.PurchaseOrderClassInfo, orders, result.DataSet); return(orders); }
/// <summary> /// Loads the Payment Plan by customer. /// </summary> /// <param name="CustomerId">The customer id.</param> /// <returns></returns> public static MetaStorageCollectionBase <PaymentPlan> LoadByCustomer(Guid CustomerId) { Guid searchGuid = Guid.NewGuid(); DataCommand cmd = OrderDataHelper.CreateTranDataCommand(); cmd.CommandText = String.Format("ecf_Search_{0}_Customer", OrderContext.Current.PaymentPlanMetaClass.Name); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("SearchSetId", searchGuid, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("CustomerId", CustomerId, DataParameterType.UniqueIdentifier)); // Might be good idea to signal if there are results at all DataService.Run(cmd); // Load results and return them back return(LoadSearchResults(searchGuid)); }