private void bwViewReport_DoWork(object sender, DoWorkEventArgs e)
 {
     linePerformanceDetailList = LinePerformanceDetailController.SelectBySection(section.SectionId, monthSearch, yearSearch);
     lineModelList             = LineController.Select(section.SectionId);
     if (selectArea == "Old")
     {
         linePerformanceDetailList = linePerformanceDetailList.Where(w => oldArr.Contains(w.LineId) == true).ToList();
         lineModelList             = lineModelList.Where(w => oldArr.Contains(w.LineId) == true).OrderBy(o => o.Ordinal).ToList();
     }
     if (selectArea == "New")
     {
         linePerformanceDetailList = linePerformanceDetailList.Where(w => newArr.Contains(w.LineId) == true).ToList();
         lineModelList             = lineModelList.Where(w => newArr.Contains(w.LineId) == true).OrderBy(o => o.Ordinal).ToList();
     }
     incentiveGradeList = IncentiveGradeModel.Select().Where(w => w.SectionId == section.SectionId).ToList();
     positionList       = linePerformanceDetailList.Select(s => s.IncentiveGrade).Distinct().ToList();
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int currentMonth = DateTime.Now.Month;

            int[] monthArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            cboMonth.ItemsSource  = monthArray;
            cboMonth.SelectedItem = currentMonth;
            int currentYear = DateTime.Now.Year;

            int[] yearArray = { currentYear - 1, currentYear };
            cboYear.ItemsSource  = yearArray;
            cboYear.SelectedItem = currentYear;
            incentiveGradeList   = IncentiveGradeModel.Select().Where(i => i.SectionId == section.SectionId).ToList();
            if (bwLoadData.IsBusy == false)
            {
                this.Cursor = Cursors.Wait;
                bwLoadData.RunWorkerAsync();
            }
        }
        private void bwViewReport_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            DataTable dt = new AssemblyIncentiveStatistics().Tables["AssemblyIncentive"];

            foreach (var line in lineModelList)
            {
                foreach (string position in positionList)
                {
                    IncentiveGradeModel incentiveGradeModel = incentiveGradeList.Where(w => w.Name == position).FirstOrDefault();
                    int incentivePerPosition = linePerformanceDetailList.Where(w => w.LineId == line.LineId && w.IncentiveGrade == position).Select(s => s.Incentive).Sum();
                    if (incentiveGradeModel != null)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Line"]      = "Line " + line.Name;
                        dr["Position"]  = incentiveGradeModel.Name;
                        dr["Incentive"] = incentivePerPosition;
                        dt.Rows.Add(dr);
                    }
                }
            }

            ReportParameter  rp1 = new ReportParameter("Month", monthName.ToUpper());
            ReportParameter  rp2 = new ReportParameter("Year", yearName.ToString());
            ReportDataSource rds = new ReportDataSource();

            rds.Name  = "AssemblyIncentivePerPosition";
            rds.Value = dt;

            //reportViewer.LocalReport.ReportPath = @"E:\SV PROJECT\SWO\Assembly\1.18.03.14\SewingIncentives\Reports\AssemblyIncentiveReport.rdlc";
            reportViewer.LocalReport.ReportPath = @"Reports\AssemblyIncentiveReport.rdlc";
            reportViewer.LocalReport.SetParameters(new ReportParameter[] { rp1, rp2 });
            reportViewer.LocalReport.DataSources.Clear();
            reportViewer.LocalReport.DataSources.Add(rds);
            reportViewer.RefreshReport();

            this.Cursor             = null;
            btnViewReport.IsEnabled = true;
        }