Example #1
0
        private void cmbScholarshipPaymentID_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;

                rptScholarshipPaymentReceipt rpt = new rptScholarshipPaymentReceipt();
                //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 ScholarshipPayment,Student,Scholarship where Student.ScholarNo=ScholarshipPayment.ScholarNo and Scholarship.ScholarshipID=ScholarshipPayment.ScholarshipID and ScholarshipPaymentID = '" + cmbScholarshipPaymentID.Text + "'";
                MyCommand.CommandType = CommandType.Text;
                myDA.SelectCommand    = MyCommand;
                myDA.Fill(myDS, "ScholarshipPayment");
                myDA.Fill(myDS, "Student");
                myDA.Fill(myDS, "Scholarship");
                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()
        {
            rptScholarshipPaymentReceipt rpt = new rptScholarshipPaymentReceipt();

            rpt.Site = this.Site;
            return(rpt);
        }
        private void Print_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;
                frmScholarshipPaymentReceipt frm = new frmScholarshipPaymentReceipt();

                rptScholarshipPaymentReceipt rpt = new rptScholarshipPaymentReceipt();
                //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 ScholarshipPayment where ScholarshipPaymentID = '" + ScholarshipPaymentID.Text + "'";

                MyCommand.CommandType = CommandType.Text;
                myDA.SelectCommand    = MyCommand;
                myDA.Fill(myDS, "ScholarshipPayment");
                rpt.SetDataSource(myDS);
                frm.crystalReportViewer1.ReportSource = rpt;
                frm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }