private void button1_Click(object sender, EventArgs e) { try { con.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("execute salesDateRangeBal @fdate,@tdate", con); da.SelectCommand.Parameters.AddWithValue("@fdate", textBox1.Text); da.SelectCommand.Parameters.AddWithValue("@tdate", textBox2.Text); DataTable dt = new DataTable(); da.Fill(dt); saleReportDateRange myreport = new saleReportDateRange(); myreport.SetDataSource(dt); SaleReportView srv = new SaleReportView(); srv.crystalReportViewer1.ReportSource = myreport; srv.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "errorr!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } }
private void button2_Click(object sender, EventArgs e) { try { con.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("execute salesDateBal @date", con); da.SelectCommand.Parameters.AddWithValue("@date", textBox3.Text); DataTable dt = new DataTable(); da.Fill(dt); salesReportDate myreport = new salesReportDate(); myreport.SetDataSource(dt); SaleReportView srv = new SaleReportView(); srv.crystalReportViewer1.ReportSource = myreport; srv.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "errorr!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } }