private void button10_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptFeesPayment rpt = new rptFeesPayment(); //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 FeePayment,Student where Student.ScholarNo=FeePayment.ScholarNo and DateOfPayment between @date1 and @date2 order by DateOfPayment"; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "DateOfPayment").Value = PaymentDateFrom.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "DateOfPayment").Value = PaymentDateTo.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "FeePayment"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer3.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptFeesPayment rpt = new rptFeesPayment(); rpt.Site = this.Site; return(rpt); }
private void button14_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptFeesPayment rpt = new rptFeesPayment(); //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 FeePayment where DateOfPayment between @date1 and @date2 and fine > 0 order by DateOfPayment "; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "DateOfPayment").Value = dateTimePicker1.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "DateOfPayment").Value = dateTimePicker2.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "FeePayment"); rpt.SetDataSource(myDS); crystalReportViewer5.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { if (ScholarNo.Text == "") { MessageBox.Show("Please select scholar no.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ScholarNo.Focus(); return; } try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptFeesPayment rpt = new rptFeesPayment(); //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 FeePayment,Student where FeePayment.ScholarNo=Student.ScholarNo and FeePayment.ScholarNo= '" + ScholarNo.Text + "'order by DateOfPayment"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "FeePayment"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer2.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }