private void btnPreview_Click(object sender, EventArgs e) { try { string vWhere = string.Empty; string criteria = string.Empty; Reports.RptReportViewer vForm = new Reports.RptReportViewer(); DateTime vFromDate = dt_From.Value; DateTime vToDate = dt_ToDate.Value; if (!string.IsNullOrEmpty(this.txtVendorID.Text)) { vWhere = " AND SaleReturn.CustomerID=" + this.txtVendorID.Text; } if (Int32.Parse(cboSalesman.SelectedValue.ToString()) > 0) { vWhere += " AND SaleReturn.SaleID IN (Select SaleID From Sale Where SalesmanID=" + cboSalesman.SelectedValue.ToString() + ")"; criteria += " Salesman: " + cboSalesman.SelectedText; } //if (!string.IsNullOrEmpty(this.txt_ProductID.Text)) //{ // vWhere += " AND SaleRetBody.ProductID=" + this.txt_ProductID.Text; //} if (optRange.Checked == true) { criteria = "From: " + dt_From.Value.ToString("dd-MMM-yyyy") + " To: " + dt_ToDate.Value.ToString("dd-MMM-yyyy"); } else { vFromDate = Convert.ToDateTime("1/1/2000"); vToDate = DateTime.Now; criteria = " Till Date: " + vToDate.ToString("dd-MMM-yyyy"); } DataTable dt = objDAL.getPartyProductWiseSale(txtVendorID.Text, int.Parse(cboSalesman.SelectedValue.ToString()), vFromDate.ToShortDateString(), vToDate.ToShortDateString()); if (dt.Rows.Count == 0) { MessageBox.Show("No Data To Display", "No Data"); return; } vForm.PartyProductWiseSale(criteria, dt); vForm.ShowDialog(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error"); } }