Esempio n. 1
0
        private void LocateInvoice()
        {
            int invoiceId = 0;

            invoiceId = Convert.ToInt32(txtInvoiceId.Text);

            Facade.IInvoice facInvoice = new Facade.Invoice();

            DataSet ds = facInvoice.GetInvoiceForInvoiceId(invoiceId);

            if (ds.Tables[0].Rows.Count != 0)
            {
                if (Convert.ToBoolean(ds.Tables[0].Rows[0]["ForCancellation"]) != true)
                {
                    // Populate ClientId Session Variable
                    int clientId = 0;
                    clientId = Convert.ToInt32(ds.Tables[0].Rows[0]["IdentityId"]);

                    //#15867 J.Steele
                    //Clear the Invoice Session variables before setting the specific ones
                    Utilities.ClearInvoiceSession();
                    Session["ClientId"] = clientId;

                    // Find which invoice page to load
                    switch ((eInvoiceType)Enum.Parse(typeof(eInvoiceType), ds.Tables[0].Rows[0]["InvoiceType"].ToString()))
                    {
                    case eInvoiceType.Normal:
                        Response.Redirect("addupdateInvoice.aspx?InvoiceId=" + invoiceId, false);
                        break;

                    case eInvoiceType.SelfBill:
                        Response.Redirect("addupdateInvoice.aspx?invoiceId=" + invoiceId, false);
                        break;

                    case eInvoiceType.OneLiner:
                        Response.Redirect("addupdateonelinerinvoice.aspx?InvoiceId=" + invoiceId, false);
                        break;

                    case eInvoiceType.SelfBillRemainder:
                        Response.Redirect("addupdateselfbillinvoice.aspx?invoiceId=" + invoiceId, false);
                        break;

                    case eInvoiceType.Extra:
                        Response.Redirect("addupdateextrainvoice.aspx?invoiceId=" + invoiceId, false);
                        break;

                    case eInvoiceType.ClientInvoicing:
                        // Register a script that spawns a new window displaying the groupage invoice pdf.
                        string pdfLocation          = Globals.Configuration.WebServer + ds.Tables[0].Rows[0]["PDFLocation"];
                        string openInvoicePdfScript = string.Format("openResizableDialogWithScrollbars('{0}', 700, 600);", pdfLocation.Replace(@"\", @"/"));
                        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "OpenInvoicePdfByInvoiceId", openInvoicePdfScript, true);
                        break;
                    }
                }
                else
                {
                    lblNote.Visible   = true;
                    lblNote.Text      = "The Invoice Id " + txtInvoiceId.Text + " has been deleted!";
                    lblNote.ForeColor = Color.Red;
                }
            }
            else
            {
                lblNote.Visible   = true;
                lblNote.Text      = "The Invoice Id " + txtInvoiceId.Text + " has not been found!";
                lblNote.ForeColor = Color.Red;
            }
        }