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); } } }
public static bool Insert(LinePerformanceModel model) { var @LineId = new SqlParameter("@LineId", model.LineId); var @Date = new SqlParameter("@Date", model.Date); var @Output = new SqlParameter("@Output", model.Output); var @PatternNo = new SqlParameter("@PatternNo", model.PatternNo); var @ArticleNo = new SqlParameter("@ArticleNo", model.ArticleNo); var @IncentiveGradeA = new SqlParameter("@IncentiveGradeA", model.IncentiveGradeA); var @ReportedWorkHour = new SqlParameter("@ReportedWorkHour", model.ReportedWorkHour); var @IncentiveGradeASmall = new SqlParameter("@IncentiveGradeASmall", model.IncentiveGradeASmall); var @ExcessIncentive = new SqlParameter("@ExcessIncentive", model.ExcessIncentive); var @QuotaTarget = new SqlParameter("@QuotaTarget", model.QuotaTarget); SaovietCheckInEntities db = new SaovietCheckInEntities(); if (db.ExecuteStoreCommand(@"EXEC spm_InsertLinePerformance_4 @LineId, @Date, @Output, @PatternNo, @ArticleNo, @IncentiveGradeA, @ReportedWorkHour, @IncentiveGradeASmall, @ExcessIncentive, @QuotaTarget", @LineId, @Date, @Output, @PatternNo, @ArticleNo, @IncentiveGradeA, @ReportedWorkHour, @IncentiveGradeASmall, @ExcessIncentive, @QuotaTarget) >= 1) { return(true); } return(false); }