示例#1
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            SampleOrderResult result = obj as SampleOrderResult;

            if (result == null)
            {
                throw new ArgumentException("obj must be a SampleOrderResult.");
            }
            return(String.Compare(OrderNumber, result.OrderNumber, true));
        }
示例#2
0
    private List <SampleOrderResult> GetSampleOrders(GridViewRow row, out int count)
    {
        GridView grid = (GridView)row.FindControl("SampleShippingCosts");

        PackageRule rule = new PackageRule(Rules.DataKeys[row.RowIndex].Value.ToString());

        rule.Matches.AddRange(
            ((BVModules_Shipping_Package_Rules_PackageMatchEditor)row.FindControl("PackageMatchEditor")).GetMatches());
        rule.Value = Decimal.Parse(((TextBox)row.FindControl("ValueField")).Text);
        rule.ValueCustomProperty       = ((DropDownList)row.FindControl("ValueCustomPropertyField")).SelectedValue;
        rule.ValueItemPropertyAsString = ((DropDownList)row.FindControl("ValueItemPropertyField")).SelectedValue;
        rule.ValuePropertyAsString     = ((DropDownList)row.FindControl("ValuePackagePropertyField")).SelectedValue;

        count = 0;

        // Scan all placed orders
        List <SampleOrderResult> results = new List <SampleOrderResult>();

        foreach (Order order in Order.FindByCriteria(new OrderSearchCriteria()))
        {
            Order heavyOrder = Order.FindByBvin(order.Bvin);

            // "Unship" all of the items so that the samples look like they
            // were just placed. Skip any orders with deleted items.
            bool skipOrder = false;
            foreach (LineItem lineitem in heavyOrder.Items)
            {
                if (lineitem.AssociatedProduct == null || lineitem.AssociatedProduct.ShippingMode == ShippingMode.None)
                {
                    skipOrder = true;
                }
                else
                {
                    lineitem.QuantityShipped = 0;
                }
            }
            if (skipOrder)
            {
                break;
            }

            int groupNumber = 0;
            foreach (ExtendedShippingGroup group in Settings.PackagingRules.Apply(heavyOrder.GetShippingGroups()))
            {
                groupNumber += 1;
                if (rule.IsMatch(group))
                {
                    count += 1;
                    if (count > grid.PageSize * 5)
                    {
                        break;
                    }
                    SampleOrderResult result = new SampleOrderResult();
                    result.OrderNumber  = order.OrderNumber;
                    result.OrderDisplay = string.Format("<a href=\"{0}\" target=\"order\">{1}</a> / {2}",
                                                        Page.ResolveUrl(
                                                            string.Format("~/BVAdmin/Orders/ViewOrder.aspx?id={0}",
                                                                          order.Bvin)),
                                                        order.OrderNumber,
                                                        string.IsNullOrEmpty(group.Name) ? "(default)" : group.Name);
                    List <string> matchValues = new List <string>();
                    List <string> limitValues = new List <string>();
                    if (rule.IsDefaultRule)
                    {
                        matchValues.Add("n/a");
                        limitValues.Add("n/a");
                    }
                    else
                    {
                        for (int index = 0; index < rule.Matches.Count; index++)
                        {
                            PackageMatch match      = rule.Matches[index];
                            string       matchValue =
                                PackagePropertiesHelper.GetPackagePropertyValue(group, match.PackageProperty,
                                                                                match.ItemProperty,
                                                                                match.CustomProperty, "1").ToString();
                            if (string.IsNullOrEmpty(matchValue))
                            {
                                matchValue = "(empty)";
                            }
                            matchValues.Add(matchValue);
                            string limitValue =
                                PackagePropertiesHelper.GetPackagePropertyValue(group, match.LimitPackageProperty,
                                                                                match.LimitItemProperty,
                                                                                match.LimitCustomProperty, match.Limit).
                                ToString();
                            if (string.IsNullOrEmpty(limitValue))
                            {
                                limitValue = "(empty)";
                            }
                            limitValues.Add(limitValue);
                        }
                    }
                    result.MatchValues = string.Join(", ", matchValues.ToArray());
                    result.LimitValues = string.Join(", ", limitValues.ToArray());
                    object value =
                        PackagePropertiesHelper.GetPackagePropertyValue(group, rule.ValuePackageProperty,
                                                                        rule.ValueItemProperty,
                                                                        rule.ValueCustomProperty, "1");
                    result.Value = value == null ? "n/a" : value.ToString();
                    if (String.IsNullOrEmpty(result.Value))
                    {
                        result.Value = "(empty)";
                    }
                    ShippingRate rate =
                        new ShippingRate(((PackageRulesEditor)NamingContainer).NameFieldText, string.Empty,
                                         string.Empty, 0, string.Empty);
                    decimal?cost = rule.GetCost(group);
                    if (cost.HasValue)
                    {
                        rate.Rate          = cost.Value;
                        result.RateDisplay = rate.RateAndNameForDisplay;
                    }
                    else
                    {
                        result.RateDisplay = "Hidden";
                    }
                    results.Add(result);
                }
            }
        }
        results.Sort();
        return(results);
    }
    private List<SampleOrderResult> GetSampleOrders(GridViewRow row, out int count)
    {
        GridView grid = (GridView) row.FindControl("SampleShippingCosts");

        OrderRule rule = new OrderRule(Rules.DataKeys[row.RowIndex].Value.ToString());
        rule.Matches.AddRange(
            ((BVModules_Shipping_Order_Rules_OrderMatchEditor) row.FindControl("OrderMatchEditor")).GetMatches());
        rule.Value = Decimal.Parse(((TextBox) row.FindControl("ValueField")).Text);
        rule.ValueCustomProperty = ((DropDownList) row.FindControl("ValueCustomPropertyField")).SelectedValue;
        rule.ValueItemPropertyAsString = ((DropDownList) row.FindControl("ValueItemPropertyField")).SelectedValue;
        rule.ValuePackagePropertyAsString = ((DropDownList) row.FindControl("ValuePackagePropertyField")).SelectedValue;
        rule.ValuePropertyAsString = ((DropDownList) row.FindControl("ValueOrderPropertyField")).SelectedValue;

        count = 0;

        // Scan all placed orders
        List<SampleOrderResult> results = new List<SampleOrderResult>();
        foreach (Order order in Order.FindByCriteria(new OrderSearchCriteria()))
        {
            Order heavyOrder = Order.FindByBvin(order.Bvin);

            // "Unship" all of the items so that the samples look like they
            // were just placed. Skip any orders with deleted items.
            bool skipOrder = false;
            foreach (LineItem lineitem in heavyOrder.Items)
            {
                if (lineitem.AssociatedProduct == null || lineitem.AssociatedProduct.ShippingMode == ShippingMode.None)
                    skipOrder = true;
                else
                    lineitem.QuantityShipped = 0;
            }
            if (skipOrder) break;

            if (rule.IsMatch(heavyOrder))
            {
                count += 1;
                if (count > grid.PageSize*5) break;
                SampleOrderResult result = new SampleOrderResult();
                result.OrderNumber = order.OrderNumber;
                result.OrderDisplay = string.Format("<a href=\"{0}\" target=\"order\">{1}</a>",
                                                    Page.ResolveUrl(
                                                        string.Format("~/BVAdmin/Orders/ViewOrder.aspx?id={0}",
                                                                      order.Bvin)),
                                                    order.OrderNumber);
                List<string> matchValues = new List<string>();
                List<string> limitValues = new List<string>();
                if (rule.IsDefaultRule)
                {
                    matchValues.Add("n/a");
                    limitValues.Add("n/a");
                }
                else
                {
                    for (int index = 0; index < rule.Matches.Count; index++)
                    {
                        OrderMatch match = rule.Matches[index];
                        string matchValue =
                            OrderPropertiesHelper.GetOrderPropertyValue(heavyOrder, match.OrderProperty, match.PackageProperty,
                            match.ItemProperty, match.CustomProperty, "1").ToString();
                        if (string.IsNullOrEmpty(matchValue)) matchValue = "(empty)";
                        matchValues.Add(matchValue);
                        string limitValue =
                            OrderPropertiesHelper.GetOrderPropertyValue(heavyOrder, match.LimitOrderProperty, match.LimitPackageProperty,
                            match.LimitItemProperty, match.LimitCustomProperty, match.Limit).ToString();
                        if (string.IsNullOrEmpty(limitValue)) limitValue = "(empty)";
                        limitValues.Add(limitValue);
                    }
                }
                result.MatchValues = string.Join(", ", matchValues.ToArray());
                result.LimitValues = string.Join(", ", limitValues.ToArray());
                object value =
                    OrderPropertiesHelper.GetOrderPropertyValue(heavyOrder, rule.ValueOrderProperty, rule.ValuePackageProperty,
                    rule.ValueItemProperty, rule.ValueCustomProperty, "1");
                result.Value = value == null ? "n/a" : value.ToString();
                if (String.IsNullOrEmpty(result.Value)) result.Value = "(empty)";
                ShippingRate rate =
                    new ShippingRate(((OrderRulesEditor) NamingContainer).NameFieldText, string.Empty, string.Empty,
                                     0, string.Empty);
                decimal? cost = rule.GetCost(heavyOrder);
                if (cost.HasValue)
                {
                    rate.Rate = cost.Value;
                    result.RateDisplay = rate.RateAndNameForDisplay;
                }
                else
                {
                    result.RateDisplay = "Hidden";
                }
                results.Add(result);
            }
        }
        results.Sort();
        return results;
    }