private void button1_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptOthersTransaction rpt = new rptOthersTransaction(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); CMS_DBDataSet myDS = new CMS_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from OtherTransaction where Date between @date1 and @date2"; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "Date").Value = DateFrom.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "Date").Value = DateTo.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "OtherTransaction"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptOthersTransaction rpt = new rptOthersTransaction(); rpt.Site = this.Site; return(rpt); }
private void button4_Click(object sender, EventArgs e) { if (cmbTransactionType.Text == "") { MessageBox.Show("Please select transaction type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbTransactionType.Focus(); return; } try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptOthersTransaction rpt = new rptOthersTransaction(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); CMS_DBDataSet myDS = new CMS_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from OtherTransaction where Date between @date1 and @date2 and transactiontype = '" + cmbTransactionType.Text + "'"; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "Date").Value = dateTimePicker1.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "Date").Value = dateTimePicker2.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "OtherTransaction"); rpt.SetDataSource(myDS); crystalReportViewer2.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }