private void btnPreview_Click(object sender, EventArgs e) { try { string vWhere = string.Empty; Reports.RptReportViewer vForm = new Reports.RptReportViewer(); if (!string.IsNullOrEmpty(this.txtVendorID.Text)) { vWhere = " AND LastPurchase.CustomerID=" + this.txtVendorID.Text; } decimal vDaysExc; decimal.TryParse(txtDaysExc.Text, out vDaysExc); vWhere += " and DATEDIFF(day, LastPurchase.LastPurchaseDate, GETDATE())>= " + vDaysExc; DataTable dt = objDAL.getPartiesAging(vWhere, Int64.Parse(cboSalesman.SelectedValue.ToString())); if (dt.Rows.Count == 0) { MessageBox.Show("No Data To Display", "No Data"); return; } vForm.PartyAging(dt); vForm.ShowDialog(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error"); } }