private void bwUpdateSizeRun_DoWork(object sender, DoWorkEventArgs e) { foreach (var model in sizeRunToUpdateList) { SizeRunController.Insert(model); } }
private void bwSaveSizeRun_DoWork(object sender, DoWorkEventArgs e) { foreach (var sizeRun in sizeRunList_OutsoleCode) { SizeRunController.Insert(sizeRun); } }
private void bwImport_DoWork(object sender, DoWorkEventArgs e) { // Insert SizeRun int i = 1; progressBar.Dispatcher.Invoke((Action)(() => progressBar.Maximum = sizeRunToImportList.Count)); foreach (SizeRunModel sizeRun in sizeRunToImportList) { SizeRunController.Insert(sizeRun); dgSizeRun.Dispatcher.Invoke((Action)(() => { dgSizeRun.SelectedItem = sizeRun; dgSizeRun.ScrollIntoView(sizeRun); })); Dispatcher.Invoke(new Action(() => { lblStatus.Text = "Importing SizeRun ..."; progressBar.Value = i; })); i++; } // Update OutsoleSize, MidSoleSize var productNoList = sizeRunToImportList.Select(s => s.ProductNo).Distinct().ToList(); var orderList = OrdersController.Select(); int indexPO = 1; progressBar.Dispatcher.Invoke((Action)(() => progressBar.Value = 0)); progressBar.Dispatcher.Invoke((Action)(() => progressBar.Maximum = productNoList.Count)); foreach (var productNo in productNoList) { var orderPerPOModel = orderList.FirstOrDefault(f => f.ProductNo == productNo); if (orderPerPOModel == null) { continue; } string outsoleCode = orderPerPOModel.OutsoleCode; string articleNo = orderPerPOModel.ArticleNo.Contains("-") ? orderPerPOModel.ArticleNo.Split('-')[0].ToString() : orderPerPOModel.ArticleNo; var sizeRunPerArticleList = SizeRunController.SelectPerArticle(articleNo).Where(w => w.UpdateOutsoleSizeByArticle == true).ToList(); var sizeRunPerOutsoleCodeList = SizeRunController.SelectPerOutsoleCode(outsoleCode).Where(w => w.UpdateOutsoleSizeByArticle == false).ToList(); if (sizeRunPerOutsoleCodeList.Count == 0 && sizeRunPerArticleList.Count == 0) { continue; } var sizeRunUpdateSizeMapList = sizeRunToImportList.Where(w => w.ProductNo == productNo).ToList(); foreach (var sizeRun in sizeRunUpdateSizeMapList) { string outsoleSize = "", midsoleSize = ""; var sizeRunInOutsoleCode = sizeRunPerOutsoleCodeList.FirstOrDefault(f => f.SizeNo == sizeRun.SizeNo); if (sizeRunPerArticleList.Count > 0) { sizeRunInOutsoleCode = sizeRunPerArticleList.FirstOrDefault(f => f.SizeNo == sizeRun.SizeNo); } if (sizeRunInOutsoleCode == null) { continue; } outsoleSize = sizeRunInOutsoleCode.OutsoleSize; midsoleSize = sizeRunInOutsoleCode.MidsoleSize; if (String.IsNullOrEmpty(outsoleSize) == true && String.IsNullOrEmpty(midsoleSize) == true) { continue; } sizeRun.OutsoleSize = outsoleSize; sizeRun.MidsoleSize = midsoleSize; sizeRun.UpdateOutsoleSizeByArticle = sizeRunPerArticleList.Count > 0 ? true : false; SizeRunController.UpdateSizeMap(sizeRun); } Dispatcher.Invoke(new Action(() => { lblStatus.Text = "Updating OutsoleSize, MidsoleSize ..."; progressBar.Value = indexPO; })); indexPO++; } }