Exemplo n.º 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            CrystalReportSalarySheet rpt = new CrystalReportSalarySheet();

            rpt.Site = this.Site;
            return(rpt);
        }
Exemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //是否为空
            if (cmbYear.SelectedIndex == -1 || cmbMonth.SelectedIndex == -1 || cmbDepartment.SelectedIndex == -1)
            {
                CommonHelper.FailedReply("不能为空!");
                return;
            }

            int  year  = int.Parse(cmbYear.Text);
            int  month = int.Parse(cmbMonth.Text);
            Guid depId = (Guid)cmbDepartment.SelectedValue;

            Guid id = ss.GetSalarySheetId(year, month, depId);


            if (id == Guid.Empty)
            {
                //生成新的工资单
                CommonHelper.FailedReply("没有工资单,请先生成工资单!");
                return;
            }
            else
            {
                DataTable dt = ss.GetSalarySheetItems(id);
                List <SalarySheetItemReport> items = new List <SalarySheetItemReport>();
                SalarySheetItemReport        item;
                foreach (DataRow dr in dt.Rows)
                {
                    item = new SalarySheetItemReport();
                    item.EmployeeName = dr["姓名"].ToString();
                    item.BaseSalary   = (decimal)dr["基本工资"];
                    item.Bonus        = (decimal)dr["奖金"];
                    item.Fine         = (decimal)dr["罚款"];
                    item.Other        = (decimal)dr["其他"];
                    items.Add(item);
                }

                CrystalReportSalarySheet report = new CrystalReportSalarySheet();
                report.SetDataSource(items);
                report.SetParameterValue("Y", year);
                report.SetParameterValue("M", month);
                report.SetParameterValue("D", cmbDepartment.Text);

                CrystalReportViewer.ReportSource = report;
            }
        }