Beispiel #1
0
        // Fourth stage. For each Order ID create a detailed document that will be inserted in place of the DOCVARIABLE field.
        // This is the final stage and the Product.Orders template does not contain DOCVARIABLE fields. So, further processing is not required.
        void richServerDetail_CalculateDocumentVariable(object sender, CalculateDocumentVariableEventArgs e)
        {
            int currentProductID = GetID(e.Arguments[0].Value);

            if (currentProductID == -1)
            {
                return;
            }

            if (productID != currentProductID)
            {
                // Get data source that contains orders for the specified product.
                // The data source is obtained from the data already filtered by supplier.
                dataDetailedForOrders = GetOrderDataFilteredbyProductAndSupplier(currentProductID);
                productID             = currentProductID;
            }

            if (e.VariableName == "OrderDetails")
            {
                RichEditDocumentServer richServerDetailDetail = new RichEditDocumentServer();
                MailMergeOptions       options = ordersRichEdit.CreateMailMergeOptions();
                options.DataSource = dataDetailedForOrders;
                options.MergeMode  = MergeMode.JoinTables;
                ordersRichEdit.MailMerge(options, richServerDetailDetail);
                e.Value   = richServerDetailDetail;
                e.Handled = true;
            }
        }
Beispiel #2
0
        protected internal virtual OrderDetailCollection GetOrderDataFilteredbyProductAndSupplier(int productID)
        {
            OrderDetailCollection orders = new OrderDetailCollection();

            foreach (Product p in dataDetailedForProducts)
            {
                if (p.ProductID == productID)
                {
                    orders.AddRange(p.OrderDetails);
                }
            }
            return(orders);
        }