Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------

        protected void btnCreatePreInvoice_Click(object sender, EventArgs e)
        {
            Orchestrator.Facade.IPreInvoice facPreInvoice = new Orchestrator.Facade.PreInvoice();
            DateTime   invoiceDate      = DateTime.Today;
            string     userName         = Page.User.Identity.Name;
            string     batchRef         = this.txtBatchRef.Text;
            List <int> selectedOrderIDs = new List <int>();

            selectedOrderIDs = this.GetOrderIdsForPreInvoice();

            if (selectedOrderIDs.Count > 0)
            {
                // Update the orders that have been flagged.
                Facade.IOrder facOrder = new Facade.Order();
                if (facOrder.FlagAsReadyToInvoice(selectedOrderIDs, userName))
                {
                    int batchID = facPreInvoice.CreateBatch(invoiceDate, selectedOrderIDs, userName);

                    try
                    {
                        if (batchID > 0)
                        {
                            // Kick off the workflow.
                            GenerateInvoiceClient gic = new GenerateInvoiceClient("Orchestrator.InvoiceService");
                            gic.GenerateGroupageInvoiceAutoRun(batchID, batchRef, new Orchestrator.Contracts.DataContracts.NotificationParty[] { }, String.Empty, String.Empty, userName);

                            this.RebindGrid();
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException exc)
                    {
                        // Not possible to send message to workflow host - send email to support.
                        Utilities.SendSupportEmailHelper("GenerateInvoiceClient.GenerateGroupageInvoiceAutoRun(int, Orchestrator.Entities.NotificationParty[], string)", exc);
                        //this.lblError.Text = exc.Message;
                        this.lblStatus.Text = "Error creating invoice: " + exc.Message;
                    }
                }
                else
                {
                    this.lblStatus.Text = "Not all Orders could be flagged as ready to invoice.";
                }
            }
            else
            {
                this.lblStatus.Text = "0 Orders could be invoiced.";
            }
        }
Ejemplo n.º 2
0
        void btnSaveChanges_Click(object sender, EventArgs e)
        {
            List <int> flaggedOrderIDs = new List <int>();

            foreach (GridItem item in grdOrders.Items)
            {
                if (item is GridDataItem)
                {
                    using (HtmlInputCheckBox chk = (HtmlInputCheckBox)item.FindControl("chkOrder"))
                    {
                        if (chk.Checked)
                        {
                            int orderID =
                                int.Parse(item.OwnerTableView.DataKeyValues[item.ItemIndex]["OrderID"].ToString());
                            flaggedOrderIDs.Add(orderID);
                        }
                    }
                }
            }

            if (flaggedOrderIDs.Count > 0)
            {
                // Update the orders that have been flagged.
                Facade.IOrder facOrder = new Facade.Order();

                if (rdoListOrderTypes.SelectedItem.Value == "Unflagged")
                {
                    facOrder.FlagAsReadyToInvoice(flaggedOrderIDs, ((Entities.CustomPrincipal)Page.User).UserName);
                }
                else
                {
                    flaggedOrderIDs.ForEach(fo => facOrder.UnflagForInvoicing(fo));
                }

                grdOrders.Rebind();
            }
        }