public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptHostelFeePayment rpt = new rptHostelFeePayment(); rpt.Site = this.Site; return(rpt); }
private void button5_Click(object sender, EventArgs e) { if (Course.Text == "") { MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Course.Focus(); return; } if (Branch.Text == "") { MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Branch.Focus(); return; } try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptHostelFeePayment rpt = new rptHostelFeePayment(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); HostelFeePayment_DBDataSet myDS = new HostelFeePayment_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 HostelFeePayment,Student,Hostel,Hostelers where Student.scholarNo=Hostelers.ScholarNo and HostelFeePayment.ScholarNo=Student.ScholarNo and Hostel.HostelName=Hostelers.Hostelname and DateOfPayment between @date1 and @date2 and Course= '" + Course.Text + "'and branch='" + Branch.Text + "' order by DateOfPayment"; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "DateOfPayment").Value = Date_from.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "DateOfPayment").Value = Date_to.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "HostelFeePayment"); myDA.Fill(myDS, "Hostel"); myDA.Fill(myDS, "Hostelers"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button14_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptHostelFeePayment rpt = new rptHostelFeePayment(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); HostelFeePayment_DBDataSet myDS = new HostelFeePayment_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from HostelFeePayment,Student,Hostel,Hostelers where Student.scholarNo=Hostelers.ScholarNo and HostelFeePayment.ScholarNo=Student.ScholarNo and Hostel.HostelName=Hostelers.Hostelname and 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, "HostelFeePayment"); myDA.Fill(myDS, "Hostel"); myDA.Fill(myDS, "Hostelers"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer5.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }