コード例 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;
                RptSalarypaymentsReport rpt = new RptSalarypaymentsReport();
                //The report you created.
                SqlConnection  myConnection = default(SqlConnection);
                SqlCommand     MyCommand    = new SqlCommand();
                SqlDataAdapter myDA         = new SqlDataAdapter();
                ERPS_DBDataSet myDS         = new ERPS_DBDataSet();
                //The DataSet you created.


                myConnection          = new SqlConnection(cs.DBcon);
                MyCommand.Connection  = myConnection;
                MyCommand.CommandText = "select *  from EmployeePayment,Employee where Employee.StaffID=EmployeePayment.StaffID and PaymentDate between @date1 and @date2 order by PaymentDate";
                MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "PaymentDate").Value = DateFrom.Value.Date;
                MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "PaymentDate").Value = DateTo.Value.Date;
                MyCommand.CommandType = CommandType.Text;
                myDA.SelectCommand    = MyCommand;
                myDA.Fill(myDS, "EmployeePayment");
                myDA.Fill(myDS, "Employee");
                rpt.SetDataSource(myDS);
                crystalReportViewer2.ReportSource = rpt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            RptSalarypaymentsReport rpt = new RptSalarypaymentsReport();

            rpt.Site = this.Site;
            return(rpt);
        }
コード例 #3
0
        private void cmbStaffName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;
                RptSalarypaymentsReport rpt = new RptSalarypaymentsReport();
                //The report you created.
                SqlConnection  myConnection = default(SqlConnection);
                SqlCommand     MyCommand    = new SqlCommand();
                SqlDataAdapter myDA         = new SqlDataAdapter();
                ERPS_DBDataSet myDS         = new ERPS_DBDataSet();
                //The DataSet you created.
                myConnection          = new SqlConnection(cs.DBcon);
                MyCommand.Connection  = myConnection;
                MyCommand.CommandText = "select *  from EmployeePayment,Employee where EmployeePayment.StaffID=Employee.StaffID and Employee.Staffname= '" + cmbStaffName.Text + "' order by PaymentDate";
                MyCommand.CommandType = CommandType.Text;
                myDA.SelectCommand    = MyCommand;
                myDA.Fill(myDS, "EmployeePayment");
                myDA.Fill(myDS, "Employee");
                rpt.SetDataSource(myDS);

                crystalReportViewer1.ReportSource = rpt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }