Beispiel #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.";
            }
        }
        /// <summary>
        /// Call the Service To Create the Batch.
        /// </summary>
        void btnCreateBatch_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                List <Contracts.DataContracts.NotificationParty> notificationParties = new List <Contracts.DataContracts.NotificationParty>();

                foreach (GridItem item in grdNotificationRecipients.SelectedItems)
                {
                    Contracts.DataContracts.NotificationParty np = new Contracts.DataContracts.NotificationParty();
                    np.FullName     = grdNotificationRecipients.MasterTableView.DataKeyValues[item.ItemIndex]["FullName"].ToString();
                    np.UserName     = grdNotificationRecipients.MasterTableView.DataKeyValues[item.ItemIndex]["UserName"].ToString();
                    np.EmailAddress = grdNotificationRecipients.MasterTableView.DataKeyValues[item.ItemIndex]["EmailAddress"].ToString();

                    notificationParties.Add(np);
                }

                try
                {
                    if (BatchID > 0)
                    {
                        if (this.SubbyInvoiceNumbers.Count == 0)
                        {
                            this.SubbyInvoiceNumbers.Add(-1, txtSubbyInvoiceNo.Text);
                        }
                        // Kick off the workflow.
                        GenerateInvoiceClient gic = new GenerateInvoiceClient("Orchestrator.InvoiceService");
                        gic.GenerateSubContractorInvoice(BatchID, notificationParties.ToArray(), chkSelfBill.Checked, this.SubbyInvoiceNumbers, ((Entities.CustomPrincipal)Page.User).UserName);

                        Server.Transfer("../../OfflineProcessInitiated.aspx");
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException exc)
                {
                    // Not possible to send message to workflow host - send email to support.
                    Utilities.SendSupportEmailHelper("GenerateInvoiceClient.GenerateSubContractorSelfBillInvoice(int, Orchestrator.Entities.NotificationParty[], string)", exc);
                    // Redirect user to an appropriate page.
                    Server.Transfer("../../OfflineProcessInitiationFailed.aspx");
                }
            }
        }
        void btnApply_Click(object sender, EventArgs e)
        {
            List <int> reject         = new List <int>();
            List <int> regenerate     = new List <int>();
            List <int> approve        = new List <int>();
            List <int> approveAndPost = new List <int>();

            // React to the user's options.
            foreach (GridDataItem row in gvPreInvoices.Items)
            {
                if (row.OwnerTableView.Name == PreInvoiceTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HtmlInputRadioButton rdoReject         = row.FindControl("rdoReject") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoRegenerate     = row.FindControl("rdoRegenerate") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApprove        = row.FindControl("rdoApprove") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApproveAndPost = row.FindControl("rdoApproveAndPost") as HtmlInputRadioButton;
                    HtmlInputCheckBox    chkUseHeadedPaper = row.FindControl("chkUseHeadedPaper") as HtmlInputCheckBox;

                    if (rdoReject.Checked)
                    {
                        reject.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }
                    else if (rdoRegenerate.Checked)
                    {
                        regenerate.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }
                    else if (rdoApprove.Checked)
                    {
                        approve.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }
                    else if (rdoApproveAndPost.Checked)
                    {
                        approveAndPost.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }

                    if (rdoApprove.Checked || rdoApproveAndPost.Checked)
                    {
                        if (chkUseHeadedPaper.Checked)
                        {
                            SetUseHeadedPaperParameter(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()), chkUseHeadedPaper.Checked);
                        }
                    }
                }
            }

            // Notify no-one.
            List <Contracts.DataContracts.NotificationParty> notificationParties = new List <Contracts.DataContracts.NotificationParty>();

            Entities.CustomPrincipal cp = (Entities.CustomPrincipal)Page.User;


            try
            {
                // Kick off the workflow (if there is anything to do).
                if (approveAndPost.Count + approve.Count + regenerate.Count + reject.Count > 0)
                {
                    GenerateInvoiceClient gic = new GenerateInvoiceClient("Orchestrator.InvoiceService");
                    gic.VerifyInvoices(approveAndPost.ToArray(), approve.ToArray(), regenerate.ToArray(), reject.ToArray(), notificationParties.ToArray(), cp.UserName);

                    Server.Transfer("reviewablegroups.aspx");
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException exc)
            {
                // Not possible to send message to workflow host - send email to support.
                Utilities.SendSupportEmailHelper("GenerateInvoiceClient.VerifyInvoices(int[], int[], int[], int[], Orchestrator.Entities.NotificationParty[], string)", exc);
                // Redirect user to an appropriate page.
                Server.Transfer("../../OfflineProcessInitiationFailed.aspx");
            }
        }
Beispiel #4
0
        void btnApply_Click(object sender, EventArgs e)
        {
            List <int> reject         = new List <int>();
            List <int> regenerate     = new List <int>();
            List <int> approve        = new List <int>();
            List <int> approveAndPost = new List <int>();

            // Persist Row Details
            SaveBatchChanges();

            // React to the user's options.
            foreach (GridDataItem row in gvPreInvoices.Items)
            {
                #region Retrieve User Options

                if (row.OwnerTableView.Name == PreInvoiceTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HtmlInputRadioButton rdoReject         = row.FindControl("rdoReject") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApprove        = row.FindControl("rdoApprove") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApproveAndPost = row.FindControl("rdoApproveAndPost") as HtmlInputRadioButton;
                    HtmlInputCheckBox    chkUseHeadedPaper = row.FindControl("chkUseHeadedPaper") as HtmlInputCheckBox;


                    HiddenField hidIsDirty = row.FindControl("hidIsDirty") as HiddenField;
                    bool        isDirty    = false;
                    bool.TryParse(hidIsDirty.Value, out isDirty);

                    if (!isDirty)
                    {
                        if (rdoReject.Checked)
                        {
                            reject.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                            Reject.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["InvoiceGenerationParametersID"]).ToString()));
                        }
                        else if (rdoApprove.Checked)
                        {
                            approve.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                            Approve.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["InvoiceGenerationParametersID"]).ToString()));
                        }
                        else if (rdoApproveAndPost.Checked)
                        {
                            approveAndPost.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                            ApproveAndPost.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["InvoiceGenerationParametersID"]).ToString()));
                        }
                        if (rdoApprove.Checked || rdoApproveAndPost.Checked)
                        {
                            if (chkUseHeadedPaper.Checked)
                            {
                                SetUseHeadedPaperParameter(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()), chkUseHeadedPaper.Checked);
                            }
                        }
                    }
                    else
                    {
                        regenerate.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                        Regenerate.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["InvoiceGenerationParametersID"]).ToString()));
                    }
                }

                #endregion
            }

            try
            {
                // Kick off the workflow (if there is anything to do).
                if (approveAndPost.Count + approve.Count + regenerate.Count + reject.Count > 0)
                {
                    LastActionDate = DateTime.Now;

                    List <Contracts.DataContracts.NotificationParty> notificationParties = new List <Contracts.DataContracts.NotificationParty>();

                    GenerateInvoiceClient gic = new GenerateInvoiceClient("Orchestrator.InvoiceService");
                    gic.VerifyInvoices(approveAndPost.ToArray(), approve.ToArray(), regenerate.ToArray(), reject.ToArray(), notificationParties.ToArray(), ((Entities.CustomPrincipal)Page.User).UserName);

                    if (ProcessActions != null)
                    {
                        ProcessActions(sender, e);
                    }

                    //gvPreInvoices.Rebind();
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException exc)
            {
                // Not possible to send message to workflow host - send email to support.
                //Utilities.SendSupportEmailHelper("GenerateInvoiceClient.VerifyInvoices(int[], int[], int[], int[], Orchestrator.Entities.NotificationParty[], string)", exc);
                // Redirect user to an appropriate page.
                //Server.Transfer("../../OfflineProcessInitiationFailed.aspx");
            }
        }