private void RunTopTwentyCallsByDuration()
 {
     DateTime periodEndDate;
     DateTime periodStartDate;
     var clientId = int.Parse(ddlClient.SelectedValue);
     if (!DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out periodEndDate) | !DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out periodStartDate))
     {
         Response.Write("<script type='text/javascript'>alert('Please select valid dates in the Start Date and End Date fields!');</script>");
     }
     else if (ddlClient.SelectedIndex == 0)
     {
         Response.Write("<script type='text/javascript'>alert('Please select a client!');</script>");
     }
     else
     {
         try
         {
             using (var client = new QCAstServiceClient())
             {
                 rptViewer.LocalReport.DataSources.Clear();
                 rptViewer.Reset();
                 var topTwenty = client.GetTop20ByDuration(clientId, periodStartDate, periodEndDate);
                 rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoiceDetail", topTwenty.AsEnumerable()));
                 rptViewer.ProcessingMode = ProcessingMode.Local;
                 rptViewer.LocalReport.ReportPath = @"Reports\Top20ByDuration.rdlc";
                 var startDate = topTwenty.OrderByDescending(p => p.CallDate).LastOrDefault().CallDate;
                 var endDate = topTwenty.OrderByDescending(p => p.CallDate).FirstOrDefault().CallDate;
                 var clientDescription = new ReportParameter("ClientDescription", ddlClient.SelectedValue);
                 var reportDescription = new ReportParameter("ReportDescription", "From : " + startDate + Environment.NewLine + "To     : " + endDate);
                 rptViewer.LocalReport.SetParameters(new ReportParameter[] { clientDescription, reportDescription });
                 rptViewer.LocalReport.Refresh();
             }
         }
         catch (Exception ex)
         {
             NotifyWebmasterOfError("Billing", "Report RunTopTwentyCallsByDuration", ex.ToString());
         }
     }
 }