private void btnPreview_Click(object sender, EventArgs e) { try { string vWhere = string.Empty; DateTime vDateFrom = Convert.ToDateTime("1/1/2000"); DateTime vDateTo = DateTime.Today.Date; if (optRange.Checked == true) { vDateFrom = dt_From.Value; vDateTo = dt_ToDate.Value; } Reports.RptReportViewer vForm = new Reports.RptReportViewer(); if (!string.IsNullOrEmpty(this.txt_ProductID.Text)) { vWhere = " AND Products.ProductID=" + this.txt_ProductID.Text; } if (chkConsumable.Checked == true) { vWhere += " AND Isnull(Products.IsRawMaterial,0)=1"; } if (chkSaleable.Checked == true) { vWhere += " AND Isnull(Products.IsRawMaterial,0)=0"; } DataTable dt = objDAL.getStockStatement(vDateFrom.ToShortDateString(), vDateTo.ToShortDateString(), vWhere); if (dt.Rows.Count == 0) { MessageBox.Show("No Data To Display", "No Data"); return; } vForm.ShowStockStatement(dt); vForm.ShowDialog(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error"); } }