Exemple #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            var emp = viewBonusDataGridView.DataSource;

            List <DL.ViewBonus> viewSalarySheets = (List <ViewBonus>)emp;



            int   bonusId = Convert.ToInt32(comboBox1.SelectedValue);
            Bonus bonus   = db.Bonus.Find(bonusId);

            DateTime To   = bonus.Date;
            DateTime From = To.AddYears(-1);

            int id = Convert.ToInt32(comboBox3.SelectedValue);

            DL.Department department = db.Departments.Find(id);

            int id2 = Convert.ToInt32(comboBox4.SelectedValue);

            DL.Section section = db.Sections.Find(id2);



            BonusCrystalPar salaryReportParameter = new BonusCrystalPar();

            salaryReportParameter.Unit       = department.Unit.Name;
            salaryReportParameter.Department = department.Name;
            salaryReportParameter.Section    = section.Name;
            salaryReportParameter.Date       = DateTime.Now;
            salaryReportParameter.BonusDate  = bonus.Date;
            salaryReportParameter.Festival   = bonus.Reason;

            // Calculate Company Wise
            List <Employee> employeesALL = db.Employees.Where(a => a.Section.Department.Unit.CompanyId == department.Unit.CompanyId).ToList();
            List <Employee> employees    = employeesALL.Where(a => a.IsActive(To) && a.IsEdited == true).ToList();

            try
            {
                List <ViewBonus> viewSalarySheetsCompany = GetList(employees);
                salaryReportParameter.CTE = viewSalarySheetsCompany.Sum(a => a.Bonus).ToString();
                salaryReportParameter.UTE = viewSalarySheetsCompany.Where(a => a.section.Department.UnitId == department.UnitId).Sum(a => a.Bonus).ToString();
                salaryReportParameter.DTE = viewSalarySheetsCompany.Where(a => a.section.DepartmentId == department.Id).Sum(a => a.Bonus).ToString();
                salaryReportParameter.STE = viewSalarySheets.Sum(a => a.Bonus).ToString();


                salaryReportParameter.CTB = viewSalarySheetsCompany.Count.ToString();
                salaryReportParameter.UTB = viewSalarySheetsCompany.Count(a => a.section.Department.UnitId == department.UnitId).ToString();
                salaryReportParameter.DTB = viewSalarySheetsCompany.Count(a => a.section.DepartmentId == department.Id).ToString();
                salaryReportParameter.STB = viewSalarySheets.Count.ToString();
            }
            catch
            {
            }



            using (BonusCrystalReport salaryCrystalReport = new BonusCrystalReport(salaryReportParameter, viewSalarySheets))
            {
                salaryCrystalReport.ShowDialog();
            }
        }
 public BonusCrystalReportCom(BonusCrystalPar salaryReportParameter, List <ViewBonus> vS)
 {
     InitializeComponent();
     viewSalarySheets      = vS;
     SalaryReportParameter = salaryReportParameter;
 }