Ejemplo n.º 1
0
    protected void btnProcessVoid_Click(object sender, EventArgs e)
    {
        MonthlyClosingProvider monthlyClosingProvider = UnityContainerHelper.Container.Resolve <MonthlyClosingProvider>();
        InvoiceProvider        invoiceProvider        = UnityContainerHelper.Container.Resolve <InvoiceProvider>();

        var query = from row in gvwData.Rows.Cast <GridViewRow>()
                    where (row.FindControl("chkVoid") as CheckBox).Checked
                    select new {
            InvoiceNo = row.Cells[1].Text
        };

        foreach (var invoice in query)
        {
            InvoiceHeader currentInvoice = invoiceProvider.GetInvoice(invoice.InvoiceNo);
            if (currentInvoice != null)
            {
                if (!monthlyClosingProvider.IsClosed(currentInvoice.BranchID, currentInvoice.Date.Month, currentInvoice.Date.Year))
                {
                    invoiceProvider.ProcessVoid(invoice.InvoiceNo, txtNotes.Text, chkVoidPaymentOnly.Checked);
                    lblStatus.Text += String.Format("Invoice <b>{0}</b> has been marked as void <br/>", currentInvoice.InvoiceNo);
                }
                else
                {
                    lblStatus.Text += String.Format("Invoice <b>{0}</b> cannot be marked as void because of monthly closing <br/>", currentInvoice.InvoiceNo);
                }
            }
        }

        txtNotes.Text = String.Empty;
        gvwData.DataBind();
    }