private void threadOtherDate_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { List <Object> results = e.Result as List <Object>; PersonalModel personal = results[0] as PersonalModel; //WorkerLoginModel workerLogin = results[1] as WorkerLoginModel; LinePerformanceDetailModel linePerformanceDetail = results[1] as LinePerformanceDetailModel; string name = ""; string position = ""; if (personal != null) { name = personal.Name; position = personal.Position; } if (linePerformanceDetail != null) { string lineWork = linePerformanceDetail.LineId; LineModel line = lineAllList.Where(l => l.LineId == lineWork).FirstOrDefault(); if (line != null) { lineWork = line.Name; } MessageBox.Show(String.Format("Id: {0}\nName: {1}\nPosition: {2}\nDate: {6:dd-MM-yyyy}\nWork at Line: LINE {3}\nOther Position: {4}\nIncentive Grade: {5}" , linePerformanceDetail.WorkerId, name, position, lineWork, linePerformanceDetail.OthersPosition, linePerformanceDetail.IncentiveGrade, linePerformanceDetail.Date), this.Title, MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Null!", this.Title, MessageBoxButton.OK, MessageBoxImage.Information); } txtCardId.IsEnabled = true; txtCardId.Focus(); txtCardId.SelectAll(); this.Cursor = null; }
private void threadSelect_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(string.Format("Error\n{0}", e.Error.Message), this.Title, MessageBoxButton.OK, MessageBoxImage.Warning); return; } List <LinePerformanceDetailModel> linePerformanceDetailList = e.Result as List <LinePerformanceDetailModel>; List <String> otherPositionList = linePerformanceDetailList.Select(l => l.OthersPosition).Distinct().ToList(); cboPosition.ItemsSource = null; cboPosition.ItemsSource = otherPositionList; dataTable = new OtherPositionListDataSet().Tables[0]; foreach (PersonalModel personal in personalList) { LinePerformanceDetailModel linePerformanceDetail = linePerformanceDetailList.Where(l => l.WorkerId == personal.WorkerId).FirstOrDefault(); if (linePerformanceDetail != null) { DataRow dr = dataTable.NewRow(); dr["WorkerId"] = personal.WorkerId; dr["Name"] = personal.Name; dr["Line"] = personal.Department; dr["Position"] = personal.Position; dr["OthersPosition"] = linePerformanceDetail.OthersPosition; dataTable.Rows.Add(dr); } } this.Cursor = null; cboPosition.IsEnabled = true; btnPrint.IsEnabled = true; }
private void threadOtherDate_DoWork(object sender, DoWorkEventArgs e) { List <Object> arguments = e.Argument as List <Object>; string cardId = arguments[0] as String; DateTime? date = arguments[1] as DateTime?; PersonalModel personal = personalList.Where(p => p.CardId == cardId || p.WorkerId == cardId).FirstOrDefault(); //WorkerLoginModel workerLogin = WorkerLoginController.SelectTop1(cardId, date.Value); LinePerformanceDetailModel linePerformanceDetail = LinePerformanceDetailController.SelectTop1(cardId, date.Value); List <Object> results = new List <Object>(); results.Add(personal); //results.Add(workerLogin); results.Add(linePerformanceDetail); e.Result = results; }
public static bool Insert(LinePerformanceDetailModel model) { var @LineId = new SqlParameter("@LineId", model.LineId); var @Date = new SqlParameter("@Date", model.Date); var @CardId = new SqlParameter("@CardId", model.CardId); var @WorkerId = new SqlParameter("@WorkerId", model.WorkerId); var @OthersPosition = new SqlParameter("@OthersPosition", model.OthersPosition); var @TimeOut = new SqlParameter("@TimeOut", model.TimeOut); var @IncentiveGrade = new SqlParameter("@IncentiveGrade", model.IncentiveGrade); var @Incentive = new SqlParameter("@Incentive", model.Incentive); var @SpecsIncentive = new SqlParameter("@SpecsIncentive", model.SpecsIncentive); var @ExcessIncentive = new SqlParameter("@ExcessIncentive", model.ExcessIncentive); SaovietCheckInEntities db = new SaovietCheckInEntities(); if (db.ExecuteStoreCommand("EXEC spm_InsertLinePerformanceDetail_1 @LineId,@Date,@CardId,@WorkerId,@OthersPosition,@TimeOut,@IncentiveGrade,@Incentive,@SpecsIncentive,@ExcessIncentive", @LineId, @Date, @CardId, @WorkerId, @OthersPosition, @TimeOut, @IncentiveGrade, @Incentive, @SpecsIncentive, @ExcessIncentive) >= 1) { return(true); } return(false); }
private void bwPrint_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { DataTable dt = new LineSummaryDataSet().Tables["LineSummaryTable"]; foreach (LineModel line in lineList) { List <WorkerLoginModel> workerLoginLineList = workerLoginList.Where(w => w.LineId == line.LineId).ToList(); List <String> workerIdList = workerLoginLineList.Select(w => w.WorkerId).Distinct().ToList(); List <PersonalModel> personalLineList = personalList.Where(p => workerIdList.Contains(p.WorkerId) == true).ToList(); int countTotalWorker = personalLineList.Where(p => p.Department != "ASSEMBLY QUALITY" && positionList.Where(p1 => p1.IsCalculate == true).Select(p1 => p1.Name).Contains(p.Position) == true).Count(); double countTotalMP = 0; int countNewWorker = 0; int count1Month = 0; int count2Months = 0; int countOldWorker = 0; foreach (PersonalModel personal in personalLineList) { WorkerFilterModel workerFilter = workerFilterList.Where(w => CalculateHelper.CalculateMonth(personal.HiredDate, date) >= w.MinMonth && CalculateHelper.CalculateMonth(personal.HiredDate, date) < w.MaxMonth).FirstOrDefault(); LinePerformanceDetailModel linePerformanceDetail = linePerformanceDetailList.Where(l => l.CardId == personal.CardId && l.WorkerId == personal.WorkerId).FirstOrDefault(); if (personal.Department != "ASSEMBLY QUALITY" && positionList.Where(p => p.IsCalculate == true).Select(p => p.Name).Contains(personal.Position) == true && workerFilter != null && (linePerformanceDetail == null || otherPositionList.Where(o => o.IsCalculate == true).Select(o => o.Name).Contains(linePerformanceDetail.OthersPosition) == true)) { countTotalMP += workerFilter.Ratio; } if (personal.Department != "ASSEMBLY QUALITY" && positionList.Where(p => p.IsCalculate == true).Select(p => p.Name).Contains(personal.Position) == true && CalculateHelper.CalculateMonth(personal.HiredDate, date) < 1 && (linePerformanceDetail == null || otherPositionList.Where(o => o.IsCalculate == true).Select(o => o.Name).Contains(linePerformanceDetail.OthersPosition) == true)) { countNewWorker += 1; } else if (personal.Department != "ASSEMBLY QUALITY" && positionList.Where(p => p.IsCalculate == true).Select(p => p.Name).Contains(personal.Position) == true && CalculateHelper.CalculateMonth(personal.HiredDate, date) >= 1 && CalculateHelper.CalculateMonth(personal.HiredDate, date) < 2 && (linePerformanceDetail == null || otherPositionList.Where(o => o.IsCalculate == true).Select(o => o.Name).Contains(linePerformanceDetail.OthersPosition) == true)) { count1Month += 1; } else if (personal.Department != "ASSEMBLY QUALITY" && positionList.Where(p => p.IsCalculate == true).Select(p => p.Name).Contains(personal.Position) == true && CalculateHelper.CalculateMonth(personal.HiredDate, date) >= 2 && CalculateHelper.CalculateMonth(personal.HiredDate, date) < 3 && (linePerformanceDetail == null || String.IsNullOrEmpty(linePerformanceDetail.OthersPosition) == true || otherPositionList.Where(o => o.IsCalculate == true).Select(o => o.Name).Contains(linePerformanceDetail.OthersPosition) == true)) { count2Months += 1; } else if (personal.Department != "ASSEMBLY QUALITY" && positionList.Where(p => p.IsCalculate == true).Select(p => p.Name).Contains(personal.Position) == true && CalculateHelper.CalculateMonth(personal.HiredDate, date) >= 3 && (linePerformanceDetail == null || String.IsNullOrEmpty(linePerformanceDetail.OthersPosition) == true || otherPositionList.Where(o => o.IsCalculate == true).Select(o => o.Name).Contains(linePerformanceDetail.OthersPosition) == true)) { countOldWorker += 1; } } int countSUP = personalLineList.Where(p => p.Position.Contains("SUPERVISOR") == true).Count(); int countMECH = personalLineList.Where(p => p.Position.Contains("MECHANIC") == true).Count(); int countMONITOR = personalLineList.Where(p => p.Position.Contains("MONITOR") == true || p.Position.Contains("MAKE BALANCE") == true).Count(); int countLL = personalLineList.Where(p => p.Position.Contains("LINE LEADER") == true).Count(); int countQC = personalLineList.Where(p => p.Department == "ASSEMBLY QUALITY" || p.Position.Contains("QC") == true).Count(); DataRow dr = dt.NewRow(); dr["Line"] = line.Name; dr["CountTotalWorker"] = countTotalWorker.ToString(); dr["CountTotalMP"] = countTotalMP.ToString(); dr["CountNewWorker"] = countNewWorker.ToString(); dr["Count1Month"] = count1Month.ToString(); dr["Count2Months"] = count2Months.ToString(); dr["CountOldWorker"] = countOldWorker.ToString(); dr["CountSUP"] = countSUP.ToString(); dr["CountMECH"] = countMECH.ToString(); dr["CountMONITOR"] = countMONITOR.ToString(); dr["CountLL"] = countLL.ToString(); dr["CountQC"] = countQC.ToString(); dt.Rows.Add(dr); } ReportParameter rp1 = new ReportParameter("Date", String.Format("{0:dd/MM/yyyy}", date)); ReportDataSource rds = new ReportDataSource(); rds.Name = "LineSummary"; rds.Value = dt; //reportViewer.LocalReport.ReportPath = @"C:\Users\IT02\Documents\Visual Studio 2010\Projects\Sewing Office Solution\SewingIncentives\Reports\LineSumaryReport.rdlc"; reportViewer.LocalReport.ReportPath = @"Reports\LineSumaryReport.rdlc"; reportViewer.LocalReport.SetParameters(new ReportParameter[] { rp1 }); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(rds); reportViewer.RefreshReport(); btnPrint.IsEnabled = true; this.Cursor = null; }