示例#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.";
            }
        }
示例#2
0
        void btnCreateBatch_Click(object sender, EventArgs e)
        {
            List <int> selectedOrderIDs = new List <int>();

            foreach (GridItem row in grdOrders.Items)
            {
                if (row.OwnerTableView.Name == grdOrders.MasterTableView.Name)
                {
                    CheckBox chk = row.FindControl("chkSelectOrder") as CheckBox;

                    if (chk != null && chk.Checked)
                    {
                        int orderID = int.Parse(row.OwnerTableView.DataKeyValues[row.ItemIndex]["OrderID"].ToString());
                        if (!selectedOrderIDs.Contains(orderID))
                        {
                            selectedOrderIDs.Add(orderID);
                        }
                    }
                }
            }

            if (selectedOrderIDs.Count > 0 && Page.IsValid)
            {
                int batchID;
                Orchestrator.Facade.IPreInvoice facPreInvoice = new Orchestrator.Facade.PreInvoice();
                userName = Page.User.Identity.Name;
                if (IsUpdate())
                {
                    batchID = int.Parse(Request.QueryString["bID"]);
                    facPreInvoice.UpdateBatch(batchID, rdiInvoiceDate.SelectedDate.Value, selectedOrderIDs, userName);
                }
                else
                {
                    batchID = facPreInvoice.CreateBatch(rdiInvoiceDate.SelectedDate.Value, selectedOrderIDs, userName);
                }
                Response.Redirect("autorunconfirmation.aspx?bID=" + batchID);
            }
        }