private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptSalarySlip  rpt          = new rptSalarySlip(); //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.
         FrmSalarySlip  frm          = new FrmSalarySlip();
         myConnection          = new SqlConnection(cs.DBConn);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "select * from EmployeePayment,Employee where Employee.StaffID=EmployeePayment.StaffID and PaymentID='" + txtPaymentID.Text + "'";
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "EmployeePayment");
         myDA.Fill(myDS, "Employee");
         rpt.SetDataSource(myDS);
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            Cursor         = Cursors.WaitCursor;
            timer1.Enabled = true;
            FrmSalarySlip frm = new FrmSalarySlip();

            frm.Show();
        }