private void bwImport_DoWork(object sender, DoWorkEventArgs e) { insockRawMaterialImportList = dgInsockRawMaterial.Items.OfType <InsockRawMaterialModel>().ToList(); progressBar.Dispatcher.Invoke((Action)(() => progressBar.Maximum = insockRawMaterialImportList.Count)); int index = 0; foreach (var insockImport in insockRawMaterialImportList) { index++; InsockRawMaterialController.Insert(insockImport); dgInsockRawMaterial.Dispatcher.Invoke((Action)(() => { dgInsockRawMaterial.SelectedItem = insockImport; dgInsockRawMaterial.ScrollIntoView(insockImport); })); progressBar.Dispatcher.Invoke((Action)(() => progressBar.Value = index)); } }
private void bwInsert_DoWork(object sender, DoWorkEventArgs e) { rawMaterial.ETD = dtDefault; rawMaterial.IsETDUpdate = true; foreach (var insockRawMaterial in insockRawMaterialViewToDeleteList) { int insockSupplierId = insockRawMaterial.InsockSupplier.InsockSupplierId; InsockRawMaterialController.Delete(productNo, insockSupplierId); } if (insockRawMaterialViewToInsertList.Count > 0) { rawMaterial.ETD = insockRawMaterialViewToInsertList.Max(m => m.ETDReal); } foreach (var insockRawMaterial in insockRawMaterialViewToInsertList) { int insockSupplierId = insockRawMaterial.InsockSupplier.InsockSupplierId; DateTime etd = TimeHelper.Convert(insockRawMaterial.ETD); if (etd != dtDefault && etd != dtNothing) { var insertModel = new InsockRawMaterialModel() { ProductNo = productNo, InsockSupplierId = insockSupplierId, ETD = etd }; InsockRawMaterialController.Insert(insertModel); if (insertModel.ETD > rawMaterial.ETD) { rawMaterial.ETD = insertModel.ETD; } } } }