Esempio n. 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            DailyWorkDistribution1RPT rpt = new DailyWorkDistribution1RPT();

            rpt.Site = this.Site;
            return(rpt);
        }
        private void btnDisplay_Click(object sender, EventArgs e)
        {
            DataSet dataSetReport    = new DataSet();
            DataSet dataSetReportSub = new DataSet();

            String   strDivisionID   = "%";
            String   strDivisionName = "ALL";
            Int32    intworktyp      = 1;
            DateTime dtFrom;
            DateTime dtTo;

            if (rbNormal.Checked)
            {
                intworktyp = 1;
            }
            else
            {
                intworktyp = 2;
            }
            if (chkAllDivisions.Checked)
            {
                strDivisionID = "%";
            }
            else
            {
                strDivisionID   = cmbDivision.SelectedValue.ToString();
                strDivisionName = cmbDivision.Text;
            }
            if (chkDateRange.Checked)
            {
                dtFrom = dtpFrom.Value.Date;
                dtTo   = dtpTo.Value.Date;
            }
            else
            {
                dtFrom = new DateTime(Convert.ToInt32(cmbYear.SelectedValue.ToString()), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), 1);
                dtTo   = new DateTime(Convert.ToInt32(cmbYear.SelectedValue.ToString()), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), 1).AddMonths(1).AddDays(-1);
            }


            dataSetReport = myReports.DailyWorkDistributionByRange(dtFrom, dtTo, strDivisionID, intworktyp, true);
            dataSetReport.WriteXml("DailyWorkDistribution.xml");

            dataSetReportSub = myReports.DailyWorkDistributionNONWorkByRange(dtFrom, dtTo, strDivisionID, intworktyp);
            dataSetReportSub.WriteXml("DailyWorkDistributionSub.xml");

            if (dataSetReport.Tables[0].Rows.Count > 0)
            {
                DailyWorkDistribution1RPT myDailyWorkDistributionRPT = new DailyWorkDistribution1RPT();
                myDailyWorkDistributionRPT.SetDataSource(dataSetReport);
                ReportViewer myReportViewer = new ReportViewer();

                myDailyWorkDistributionRPT.SetParameterValue("Estate", myDivision.ListEstate().Rows[0][1].ToString());
                myDailyWorkDistributionRPT.SetParameterValue("DivisionName", strDivisionName);

                myDailyWorkDistributionRPT.SetParameterValue("Period", "From : " + dtFrom.ToShortDateString() + " To : " + dtTo.ToShortDateString());

                if (intworktyp == 1)
                {
                    myDailyWorkDistributionRPT.SetParameterValue("WorkType", "For Normal Work");
                }
                else
                {
                    myDailyWorkDistributionRPT.SetParameterValue("WorkType", "For Cash Work");
                }
                myDailyWorkDistributionRPT.SetParameterValue("HalfNames", "(Including Half Names)");
                myReportViewer.crystalReportViewer1.ReportSource = myDailyWorkDistributionRPT;
                myReportViewer.Show();
            }
            else
            {
                MessageBox.Show("No Data To Preview");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            DataSet dataSetReport    = new DataSet();
            DataSet dataSetReportSub = new DataSet();

            String strDivisionID = "%";
            Int32  intworktyp    = 1;

            if (rbNormal.Checked)
            {
                intworktyp = 1;
            }
            else
            {
                intworktyp = 2;
            }
            if (chkAllDivisions.Checked)
            {
                strDivisionID = "%";
            }
            else
            {
                strDivisionID = cmbDivision.SelectedValue.ToString();
            }
            if (chkDateRange.Checked)
            {
                dataSetReport = myReports.DailyWorkDistributionByRange(dtpFrom.Value.Date, dtpTo.Value.Date, strDivisionID, intworktyp, false);
                dataSetReport.WriteXml("DailyWorkDistribution.xml");

                dataSetReportSub = myReports.DailyWorkDistributionNONWorkByRange(dtpFrom.Value.Date, dtpTo.Value.Date, strDivisionID, intworktyp);
                dataSetReportSub.WriteXml("DailyWorkDistributionSub.xml");
            }
            else
            {
                dataSetReport = myReports.DailyWorkDistribution(Convert.ToInt32(cmbMonth.SelectedValue.ToString()), Convert.ToInt32(cmbYear.SelectedValue.ToString()), strDivisionID, intworktyp, false);
                dataSetReport.WriteXml("DailyWorkDistribution.xml");

                dataSetReportSub = myReports.DailyWorkDistributionNONWork(Convert.ToInt32(cmbMonth.SelectedValue.ToString()), Convert.ToInt32(cmbYear.SelectedValue.ToString()), strDivisionID, intworktyp);
                dataSetReportSub.WriteXml("DailyWorkDistributionSub.xml");
            }
            if (dataSetReport.Tables[0].Rows.Count > 0)
            {
                DailyWorkDistribution1RPT myDailyWorkDistributionRPT = new DailyWorkDistribution1RPT();
                myDailyWorkDistributionRPT.SetDataSource(dataSetReport);
                ReportViewer myReportViewer = new ReportViewer();

                myDailyWorkDistributionRPT.SetParameterValue("Estate", myDivision.ListEstate().Rows[0][1].ToString());
                myDailyWorkDistributionRPT.SetParameterValue("DivisionName", "ALL");
                if (chkDateRange.Checked)
                {
                    myDailyWorkDistributionRPT.SetParameterValue("Period", "From : " + dtpFrom.Value.Date.ToShortDateString() + " To : " + dtpTo.Value.Date.ToShortDateString());
                }
                else
                {
                    myDailyWorkDistributionRPT.SetParameterValue("Period", "Month : " + cmbMonth.Text + " / " + cmbYear.Text);
                }
                if (intworktyp == 1)
                {
                    myDailyWorkDistributionRPT.SetParameterValue("WorkType", "For Normal Work");
                }
                else
                {
                    myDailyWorkDistributionRPT.SetParameterValue("WorkType", "For Cash Work");
                }
                myReportViewer.crystalReportViewer1.ReportSource = myDailyWorkDistributionRPT;
                myReportViewer.Show();
            }
            else
            {
                MessageBox.Show("No Data To Preview");
            }
        }