private void Print_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         frmFeePaymentReceipt frm = new frmFeePaymentReceipt();
         rptFeePaymentReceipt rpt = new rptFeePaymentReceipt();
         //The report you created.
         SqlConnection  myConnection = default(SqlConnection);
         SqlCommand     MyCommand    = new SqlCommand();
         SqlDataAdapter myDA         = new SqlDataAdapter();
         CMS_DBDataSet1 myDS         = new CMS_DBDataSet1();
         myConnection          = new SqlConnection(cs.DBConn);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "select * from feepayment,Student where student.Scholarno=FeePayment.ScholarNo and FeePaymentID= '" + FeePaymentID.Text + "'";
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "FeePayment");
         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 Print_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;
                frmFeePaymentReceipt frm = new frmFeePaymentReceipt();

                rptFeePaymentReceipt rpt = new rptFeePaymentReceipt();
                //The report you created.
                SqlConnection        myConnection = default(SqlConnection);
                SqlCommand           MyCommand    = new SqlCommand();
                SqlDataAdapter       myDA         = new SqlDataAdapter();
                FeePayment_DBDataSet myDS         = new FeePayment_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 FeePaymentID= '" + FeePaymentID.Text + "'";

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