private void bwImport_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (OutsoleRawMaterialViewModel outsoleRawMaterialView in outsoleRawMaterialViewToImportList)
     {
         OutsoleRawMaterialModel model = new OutsoleRawMaterialModel
         {
             ProductNo         = outsoleRawMaterialView.ProductNo,
             OutsoleSupplierId = outsoleRawMaterialView.Supplier.OutsoleSupplierId,
             ETD = outsoleRawMaterialView.ETDReal,
         };
         OutsoleRawMaterialController.Insert(model);
         dgSizeRun.Dispatcher.Invoke((Action)(() =>
         {
             dgSizeRun.SelectedItem = outsoleRawMaterialView;
             dgSizeRun.ScrollIntoView(outsoleRawMaterialView);
         }));
     }
 }
        private void bwInsert_DoWork(object sender, DoWorkEventArgs e)
        {
            rawMaterial.ETD         = dtDefault;
            rawMaterial.IsETDUpdate = true;
            foreach (OutsoleRawMaterialViewModel outsoleRawMaterialView in outsoleRawMaterialViewToDeleteList)
            {
                int outsoleSupplierId = outsoleRawMaterialView.Supplier.OutsoleSupplierId;
                OutsoleRawMaterialController.Delete(productNo, outsoleSupplierId);
            }

            if (outsoleRawMaterialViewToInsertList.Count > 0)
            {
                rawMaterial.ETD = outsoleRawMaterialViewToInsertList.Max(o => o.ETDReal);
            }

            foreach (OutsoleRawMaterialViewModel outsoleRawMaterialView in outsoleRawMaterialViewToInsertList)
            {
                int      outsoleSupplierId = outsoleRawMaterialView.Supplier.OutsoleSupplierId;
                DateTime etd = TimeHelper.Convert(outsoleRawMaterialView.ETD);
                if (etd != dtDefault && etd != dtNothing)
                {
                    OutsoleRawMaterialModel model = new OutsoleRawMaterialModel
                    {
                        ProductNo         = productNo,
                        OutsoleSupplierId = outsoleSupplierId,
                        ETD = etd,
                    };

                    OutsoleRawMaterialController.Insert(model);
                    if (model.ETD > rawMaterial.ETD)
                    {
                        rawMaterial.ETD = model.ETD.Date;
                    }
                }
            }
        }