public Guid?GetSoldToIdForPurchaseOrderByInvoice(string poNumber)
        {
            System.Data.DataSet searchableProperties = Svc.Impl.Helpers.CommerceServerCore.GetPoManager().GetSearchableProperties(System.Globalization.CultureInfo.CurrentUICulture.ToString());
            SearchClauseFactory searchClauseFactory  = Svc.Impl.Helpers.CommerceServerCore.GetPoManager().GetSearchClauseFactory(searchableProperties, "PurchaseOrder");
            SearchClause        poCluase             = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "TrackingNumber", poNumber);
            //SearchClause customerClause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "CustomerId", customerNumber);
            //SearchClause branchClause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "BranchId", branchId);
            //SearchClause invoiceClause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "Masternumber", invoiceNumber);
            //SearchClause joinedClause = searchClauseFactory.IntersectClauses(branchClause, invoiceClause);

            // Create search options.
            SearchOptions options = new SearchOptions();

            options.PropertiesToReturn      = "SoldToId";
            options.SortProperties          = "SoldToId";
            options.NumberOfRecordsToReturn = 1;

            // Perform the search.
            System.Data.DataSet results = Svc.Impl.Helpers.CommerceServerCore.GetPoManager().SearchPurchaseOrders(poCluase, options);

            if (results.Tables.Count > 0 && results.Tables[0].Rows.Count > 0)
            {
                // Enumerate the results of the search.
                return(Guid.Parse(results.Tables[0].Rows[0].ItemArray[2].ToString()));
            }
            else
            {
                return(null);
            }
        }
        private PurchaseOrder GetCsPurchaseOrderByNumber(string controlNumber)
        {
            System.Data.DataSet searchableProperties = Svc.Impl.Helpers.CommerceServerCore.GetPoManager().GetSearchableProperties(System.Globalization.CultureInfo.CurrentUICulture.ToString());
            SearchClauseFactory searchClauseFactory  = Svc.Impl.Helpers.CommerceServerCore.GetPoManager().GetSearchClauseFactory(searchableProperties, "PurchaseOrder");
            SearchClause        trackingNumberClause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "TrackingNumber", controlNumber);

            // Create search options.

            SearchOptions options = new SearchOptions();

            options.PropertiesToReturn      = "SoldToId";
            options.SortProperties          = "SoldToId";
            options.NumberOfRecordsToReturn = 1;
            // Perform the search.
            System.Data.DataSet results = Svc.Impl.Helpers.CommerceServerCore.GetPoManager().SearchPurchaseOrders(trackingNumberClause, options);

            if (results.Tables.Count > 0 && results.Tables[0].Rows.Count > 0)
            {
                try {
                    // Enumerate the results of the search.
                    Guid soldToId = Guid.Parse(results.Tables[0].Rows[0].ItemArray[2].ToString());

                    // get the guids for the customers associated users and loop if necessary
                    PurchaseOrder po = Svc.Impl.Helpers.CommerceServerCore.GetOrderContext().GetPurchaseOrder(soldToId, controlNumber);
                    return(po);
                } catch (Exception ex) {
                    _log.WriteWarningLog("Could not locate POs for user's ID. This is not an exception, just a notice.", ex);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public XmlElement GetUnconfirmatedOrders()
        {
            var manager = Extensions.SiteHelper.GetOrderManageContext().PurchaseOrderManager;

            System.Data.DataSet searchableProperties = manager.GetSearchableProperties(CultureInfo.CurrentUICulture.ToString());
            SearchClauseFactory searchClauseFactory  = manager.GetSearchClauseFactory(searchableProperties, "PurchaseOrder");
            SearchClause        clause  = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "Status", "Submitted");
            DataSet             results = manager.SearchPurchaseOrders(clause, new SearchOptions()
            {
                NumberOfRecordsToReturn = 100, PropertiesToReturn = "OrderGroupId,LastModified,SoldToId"
            });

            int c = results.Tables.Count;

            // Get the value of the OrderGroupId property of each
            // purchase order.
            List <Guid> poIds = new List <Guid>();

            foreach (DataRow row in results.Tables[0].Rows)
            {
                poIds.Add(new Guid(row["OrderGroupId"].ToString()));
            }
            // Get the XML representation of the purchase orders.
            return(manager.GetPurchaseOrdersAsXml(poIds.ToArray()));
        }
        public List <PurchaseOrder> GetPurchaseOrdersByStatus(string queryStatus)
        {
            var manager = CommerceServerCore.GetPoManager();

            System.Data.DataSet searchableProperties = manager.GetSearchableProperties(CultureInfo.CurrentUICulture.ToString());
            // set what to search
            SearchClauseFactory searchClauseFactory = manager.GetSearchClauseFactory(searchableProperties, "PurchaseOrder");
            // Get a list of the returnable properties - debug only
            //DataSet ret = manager.GetReturnableProperties("EN");
            //StringBuilder props = new StringBuilder();
            //foreach (DataRow row in ret.Tables[0].Rows)
            //{
            //    if (props.Length > 0) props.Append(",");
            //    props.Append(row.ItemArray[0].ToString());
            //}
            // set what field/value to search for
            SearchClause clause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "Status", queryStatus);
            // set what fields to return
            DataSet results = manager.SearchPurchaseOrders(clause, new SearchOptions()
            {
                NumberOfRecordsToReturn = 100, PropertiesToReturn = "OrderGroupId,TrackingNumber"
            });

            int c = results.Tables.Count;

            List <PurchaseOrder> Pos   = new List <PurchaseOrder>();
            List <string>        poTNs = new List <string>();

            foreach (DataRow row in results.Tables[0].Rows)
            {
                poTNs.Add(row["TrackingNumber"].ToString());
            }
            // Get the XML representation of the purchase orders.
            if (poTNs.Count > 0)
            {
                foreach (string trackingNumber in poTNs)
                {
                    PurchaseOrder po = ReadPurchaseOrderByTrackingNumber(trackingNumber);
                    Pos.Add(po);
                }
            }
            return(Pos);
        }
        public List <PurchaseOrder> ReadPurchaseOrderHeadersByCustomerId(Guid customerId)
        {
            var manager = CommerceServerCore.GetPoManager();

            System.Data.DataSet searchableProperties = manager.GetSearchableProperties(CultureInfo.CurrentUICulture.ToString());
            // set what to search
            SearchClauseFactory searchClauseFactory = manager.GetSearchClauseFactory(searchableProperties, "PurchaseOrder");
            // set what field/value to search for
            SearchClause clause = searchClauseFactory.CreateClause(ExplicitComparisonOperator.Equal, "SoldToId", customerId.ToCommerceServerFormat());
            // set what fields to return
            DataSet results = manager.SearchPurchaseOrders(clause,
                                                           new SearchOptions()
            {
                PropertiesToReturn = "OrderGroupId,TrackingNumber,Created"
            });

            List <PurchaseOrder> Pos   = new List <PurchaseOrder>();
            List <string>        poTNs = new List <string>();

            foreach (DataRow row in results.Tables[0].Rows)
            {
                DateTime created = (DateTime)row["Created"];
                if (created > DateTime.Now.AddDays(int.Parse(Configuration.PurchaseOrdersGetLatestHowManyDays) * -1))
                {
                    poTNs.Add(row["TrackingNumber"].ToString());
                }
            }
            if (poTNs.Count > 0)
            {
                foreach (string trackingNumber in poTNs)
                {
                    PurchaseOrder po = ReadPurchaseOrderByTrackingNumber(trackingNumber);
                    Pos.Add(po);
                }
            }
            return(Pos);
        }