Exemplo n.º 1
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if ((int)cmbPayrollPeriod.SelectedValue == 0 || cmbPayrollPeriod.SelectedValue == null)
            {
                Validation.FocusComboBox(cmbPayrollPeriod, "Payroll Period");
                return;
            }
            else if (cmbEmpType.Text == "")
            {
                Validation.FocusComboBox(cmbEmpType, "Employee Type");
                return;
            }
            else
            {
                frmRptViewer frm        = new frmRptViewer();
                string       exeFolder  = Path.GetDirectoryName(Application.StartupPath);
                string       reportPath = Path.Combine(exeFolder, "..\\Reports\\RptPayrollList.rdlc");
                frm.reportViewer1.LocalReport.ReportPath = reportPath;
                ReportParameter generatedBy = new ReportParameter("UserFullName", GlobalSession.UserFullName);

                var list = _payrollService.GetPayrollList((int)cmbPayrollPeriod.SelectedValue, cmbEmpType.Text);
                frm.reportViewer1.LocalReport.DataSources.Clear();
                ReportDataSource rs = new ReportDataSource {
                    Name = "ds_payroll", Value = list
                };

                frm.reportViewer1.LocalReport.DataSources.Add(rs);
                frm.reportViewer1.PrinterSettings.DefaultPageSettings.Landscape = true;
                frm.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { generatedBy });

                frm.ShowDialog();
            }
        }