private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            List <AssemblySpecialIncentiveModel> assySpecialIncentiveCalculateList = new List <AssemblySpecialIncentiveModel>();
            List <AssemblySpecialIncentiveModel> assySpecialIncentiveTempList      = new List <AssemblySpecialIncentiveModel>();

            assySpecialIncentiveTempList = dgSpecialIncentive.Items.OfType <AssemblySpecialIncentiveModel>().ToList();

            foreach (var assySpecialIncentive in assySpecialIncentiveTempList)
            {
                AssemblySpecialIncentiveModel assySpecialIncentiveTemp = new AssemblySpecialIncentiveModel();
                assySpecialIncentiveTemp.Line        = assySpecialIncentive.Line;
                assySpecialIncentiveTemp.Output      = assySpecialIncentive.Output;
                assySpecialIncentiveTemp.QuotaTarget = assySpecialIncentive.QuotaTarget;

                assySpecialIncentiveTemp.Lacking       = assySpecialIncentiveTemp.QuotaTarget - assySpecialIncentiveTemp.Output;
                assySpecialIncentiveTemp.PercentOutput = Math.Round((double)assySpecialIncentiveTemp.Output * 100 / (double)assySpecialIncentiveTemp.QuotaTarget, 2, MidpointRounding.AwayFromZero);

                assySpecialIncentiveTemp.SUPIncentive      = assySpecialIncentive.SUPIncentive;
                assySpecialIncentiveTemp.LLT1MECHIncentive = assySpecialIncentive.LLT1MECHIncentive;
                assySpecialIncentiveTemp.LL23Incentive     = assySpecialIncentive.LL23Incentive;
                assySpecialIncentiveTemp.WorkerIncentive   = assySpecialIncentive.WorkerIncentive;

                assySpecialIncentiveCalculateList.Add(assySpecialIncentiveTemp);
            }

            dgSpecialIncentive.ItemsSource = null;
            dgSpecialIncentive.ItemsSource = assySpecialIncentiveCalculateList;
        }
        private void bwSpecialIncentive_DoWork(object sender, DoWorkEventArgs e)
        {
            linePerformanceList = LinePerformanceController.SelectBySection(section.SectionId, monthSearch, yearSearch);
            lineModelList       = LineController.Select(section.SectionId).OrderBy(o => o.Ordinal).ToList();
            foreach (var lineModel in lineModelList)
            {
                LinePerformanceModel linePerformanceModel = linePerformanceList.Where(w => w.LineId == lineModel.LineId).FirstOrDefault();
                if (linePerformanceModel != null)
                {
                    AssemblySpecialIncentiveModel assySpecialIncentive = new AssemblySpecialIncentiveModel();
                    assySpecialIncentive.Line          = "Line " + lineModel.Name;
                    assySpecialIncentive.Output        = linePerformanceList.Where(w => w.LineId == lineModel.LineId).Select(s => s.Output).Sum();
                    assySpecialIncentive.QuotaTarget   = linePerformanceList.Where(w => w.LineId == lineModel.LineId).Select(s => s.QuotaTarget).Sum();
                    assySpecialIncentive.Lacking       = assySpecialIncentive.QuotaTarget - assySpecialIncentive.Output;
                    assySpecialIncentive.PercentOutput = Math.Round((double)assySpecialIncentive.Output * 100 / (double)assySpecialIncentive.QuotaTarget, 2, MidpointRounding.AwayFromZero);

                    assemblySpecialIncentiveList.Add(assySpecialIncentive);
                }
            }
        }