public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { CreditVoucherByCreditACCrystalReport rpt = new CreditVoucherByCreditACCrystalReport(); rpt.Site = this.Site; return rpt; }
public void Read(string srr) { //SqlConnection conn = new SqlConnection(this.connectionString); //SqlCommand comm = new SqlCommand("dbo.UspCreditVoucherCreditACWiseReport", conn); //comm.CommandType = CommandType.StoredProcedure; //comm.Parameters.Add("@Credit", SqlDbType.VarChar, 50); //comm.Parameters["@Credit"].Value = comboBox1.Text; //SqlDataAdapter adap = new SqlDataAdapter(); //DataSets.CreditVoucher dataset = new DataSets.CreditVoucher(); //Reports.CreditVoucherByCreditACCrystalReport crp = new Reports.CreditVoucherByCreditACCrystalReport(); //try //{ // conn.Open(); // adap.SelectCommand = comm; // adap.Fill(dataset, "DataTable1"); // crp.SetDataSource(dataset); // crystalReportViewer1.ReportSource = crp; //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message.ToString()); //} //finally //{ // conn.Close(); //} this.reportQuary = dateTimePicker1.Text + " to " + dateTimePicker2.Text; string query = ""; query = "Select * From TbDailyExpense Where ExpenseDate BETWEEN '" + dateTimePicker1.Value.Date + "' AND '" + dateTimePicker2.Value.Date + "' AND Credit = @Credit Order By ExpenseDate"; if (query != "") { SqlConnection conn = new SqlConnection(this.connectionString); SqlCommand comm = new SqlCommand(query, conn); comm.Parameters.Add("@Credit", SqlDbType.VarChar, 50); comm.Parameters["@Credit"].Value = comboBox1.Text; SqlDataAdapter adap = new SqlDataAdapter(); DataSets.CreditVoucher dataset = new DataSets.CreditVoucher(); CreditVoucherByCreditACCrystalReport crp = new CreditVoucherByCreditACCrystalReport(); try { conn.Open(); adap.SelectCommand = comm; adap.Fill(dataset, "DataTable1"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { conn.Close(); } crp.SetDataSource(dataset); ParameterValues v = new ParameterValues(); ParameterDiscreteValue dv = new ParameterDiscreteValue(); dv = new ParameterDiscreteValue(); dv.Value = this.reportQuary; v.Add(dv); crp.DataDefinition.ParameterFields["report_query"].ApplyCurrentValues(v); crystalReportViewer2.ReportSource = crp; } }