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