Ejemplo n.º 1
0
        protected void BtnCreateInvoiceClick(object sender, EventArgs e)
        {
            lblError.Text   = "";
            lblSuccess.Text = "";
            DateTime endDate;
            var      idUser   = int.Parse(Session["IdUser"].ToString());
            var      idClient = int.Parse(ddlClients.SelectedValue);

            if (DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd",
                                       CultureInfo.InvariantCulture, DateTimeStyles.None, out endDate))
            {
                try
                {
                    using (var client = new QCAstServiceClient())
                    {
                        bool success = client.CreateInvoice(idClient, endDate, idUser);
                        if (success)
                        {
                            lblSuccess.Text = "Invoice has been successfully captured in the database.";
                            ClearListBoxes();
                        }
                        else
                        {
                            lblError.Text =
                                "The website encountered a problem creating an invoice. The webmaster has been notified and will be attending to the problem.";
                        }
                    }
                }
                catch (Exception ex)
                {
                    NotifyWebmasterOfError("Billing", "AdminBilling btnCreateInvoice", ex.ToString());
                    lblError.Text =
                        "The website encountered a problem creating an invoice.  The webmaster has been notified and will be attending to the problem.";
                }
            }
            else
            {
                Response.Write("<script type='text/javascript'>alert('Please enter a valid date');</script>");
            }
        }