private void cmbFeePaymentID_SelectedIndexChanged(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptBusFeePaymentReceipt rpt = new rptBusFeePaymentReceipt(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from BusFeePayment,Student,Transportation,BusHolders where Student.scholarNo=BusHolders.ScholarNo and BusFeePayment.ScholarNo=Student.ScholarNo and Transportation.SourceLocation=BusHolders.SourceLocation and FeePaymentID= '" + cmbFeePaymentID.Text + "'"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "BusFeePayment"); myDA.Fill(myDS, "Transportation"); myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Print_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; frmBusFeePaymentReceipt frm = new frmBusFeePaymentReceipt(); rptBusFeePaymentReceipt rpt = new rptBusFeePaymentReceipt(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection("Data Source=.\\SqlExpress; Integrated Security=True; AttachDbFilename=|DataDirectory|\\CMS_DB.mdf; User Instance=true;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from BusFeePayment,Student,Transportation,BusHolders where Student.scholarNo=BusHolders.ScholarNo and BusFeePayment.ScholarNo=Student.ScholarNo and Transportation.SourceLocation=BusHolders.SourceLocation and FeePaymentID= '" + FeePaymentID.Text + "'"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "BusFeePayment"); myDA.Fill(myDS, "Transportation"); myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); frm.crystalReportViewer1.ReportSource = rpt; frm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ScholarNo_SelectedIndexChanged(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptBusHolders rpt = new rptBusHolders(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_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 BusHolders,Student where Student.ScholarNo=BusHolders.ScholarNo and Student.ScholarNo= '" + ScholarNo.Text + "' order by Student_name "; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer2.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtSourceLocation_TextChanged(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptBusHolders rpt = new rptBusHolders(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from BusHolders,Student where Student.ScholarNo=BusHolders.ScholarNo and SourceLocation like '" + txtSourceLocation.Text + "%' order by Student_name "; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer5.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button5_Click(object sender, EventArgs e) { try { 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; } Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptBusHolders rpt = new rptBusHolders(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_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 BusHolders,Student where Student.ScholarNo=BusHolders.ScholarNo and StartingDate between @date1 and @date2 and Course= '" + Course.Text + "'and branch='" + Branch.Text + "' order by Student_name "; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "StartingDate").Value = Date_from.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "StartingDate").Value = Date_to.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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; rptBusFeePayment rpt = new rptBusFeePayment(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from BusFeePayment,Student,Transportation,BusHolders where Student.scholarNo=BusHolders.ScholarNo and BusFeePayment.ScholarNo=Student.ScholarNo and Transportation.SourceLocation=BusHolders.SourceLocation 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, "BusFeePayment"); myDA.Fill(myDS, "Transportation"); myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button4_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptBusHolders rpt = new rptBusHolders(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBConn); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from BusHolders,Student where Student.ScholarNo=BusHolders.ScholarNo and StartingDate between @date1 and @date2 order by Student_name "; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "StartingDate").Value = dateTimePicker1.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "StartingDate").Value = dateTimePicker2.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer4.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; rptBusFeePayment rpt = new rptBusFeePayment(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); TransportationFacility_DBDataSet myDS = new TransportationFacility_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 BusFeePayment,Student,Transportation,BusHolders where Student.scholarNo=BusHolders.ScholarNo and BusFeePayment.ScholarNo=Student.ScholarNo and Transportation.SourceLocation=BusHolders.SourceLocation 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, "BusFeePayment"); myDA.Fill(myDS, "Transportation"); myDA.Fill(myDS, "BusHolders"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer5.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }