Beispiel #1
0
        private void RunInvoiceHistory()
        {
            lblError.Text = "";
            try
            {
                var idClient  = int.Parse(ddlClients.SelectedValue);
                var idInvoice = int.Parse(ddlClientInvoiceHistory.SelectedValue);
                using (var client = new QCAstServiceClient())
                {
                    rptViewer.LocalReport.DataSources.Clear();
                    rptViewer.Reset();
                    var invoiceDate      = client.GetInvoiceDate(idInvoice);
                    var invoiceDetails   = client.GetInvoicedDetailsForClient(idClient, idInvoice);
                    var invoiceSummaries = client.GetInvoicedSummaryForClient(idClient, idInvoice);
                    if (invoiceDetails.Count == 0)
                    {
                        lblError.Text = string.Format("No data available for Client {0}", ddlClients.SelectedItem.Text);
                    }
                    else
                    {
                        var rdInvDetail = new ReportDataSource("dsInvoiceDetail",
                                                               invoiceDetails.AsEnumerable());
                        var rdInvSummary = new ReportDataSource("dsInvoiceSummary",
                                                                invoiceSummaries.AsEnumerable());

                        rptViewer.LocalReport.DataSources.Add(rdInvDetail);
                        rptViewer.LocalReport.DataSources.Add(rdInvSummary);
                        rptViewer.ProcessingMode         = ProcessingMode.Local;
                        rptViewer.LocalReport.ReportPath = @"Reports\InvoiceDetail.rdlc";

                        var startDate =
                            invoiceDetails.OrderByDescending(p => p.CallDate).LastOrDefault().CallDate.ToString();
                        var endDate =
                            invoiceDetails.OrderByDescending(p => p.CallDate).FirstOrDefault().CallDate.ToString();

                        var clientDescription = new ReportParameter("ClientDescription",
                                                                    ddlClients.SelectedItem.ToString());
                        var reportDescription = new ReportParameter("ReportDescription",
                                                                    "From : " + startDate +
                                                                    Environment.NewLine + "To     : " +
                                                                    endDate);
                        var totalDuration = new ReportParameter("TotalDuration",
                                                                client.GetTotalDuration(idClient, invoiceDate));
                        rptViewer.LocalReport.SetParameters(new ReportParameter[]
                        {
                            clientDescription, reportDescription, totalDuration
                        });
                        rptViewer.LocalReport.Refresh();
                        btnCreateInvoice.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                NotifyWebmasterOfError("Billing", "AdminBilling RunInvoiceHistory", ex.ToString());
                lblError.Text =
                    "The website encountered a problem retrieving the invoice detail for this report. The webmaster has been notified and will be attending to the problem.";
            }
        }