private void LoadImportantPartCompleted(LoadOperation <ProductManager.Web.Model.important_part> aLoadOperation) { ImportantPartEntityList.Clear(); foreach (ProductManager.Web.Model.important_part important_part in aLoadOperation.Entities) { ImportantPartEntity importantPartEntity = new ImportantPartEntity(); importantPartEntity.ImportantPart = important_part; importantPartEntity.UserEntityDictionary = UserEntityDictionary; importantPartEntity.Update(); ProjectEntity projectEntityTemp; if (ProjectEntityDictionary.TryGetValue(importantPartEntity.ManufactureNumber, out projectEntityTemp)) { importantPartEntity.ProjectName = projectEntityTemp.ProjectName; } if (ProjectNameSearch != null && ProjectNameSearch.Length > 0) { if (!importantPartEntity.ProjectName.ToLower().Contains(ProjectNameSearch.ToLower())) { continue; } } ImportantPartEntityList.Add(importantPartEntity); } IsBusy = false; }
void importantPartWindow_Closed(object sender, EventArgs e) { ImportantPartWindow importantPartWindow = sender as ImportantPartWindow; if (importantPartWindow.DialogResult == true) { ImportantPartEntityList.Add(AddImportantPartEntity); productDomainContext.important_parts.Add(AddImportantPartEntity.ImportantPart); IsBusy = true; SubmitOperation submitOperation = productDomainContext.SubmitChanges(); submitOperation.Completed += submitOperation_Completed; } }
private void LoadImportantPartCompleted(LoadOperation <ProductManager.Web.Model.important_part> aLoadOperation) { ImportantPartEntityList.Clear(); foreach (ProductManager.Web.Model.important_part important_part in aLoadOperation.Entities) { ImportantPartEntity importantPartEntity = new ImportantPartEntity(); importantPartEntity.ImportantPart = important_part; importantPartEntity.UserEntityDictionary = UserEntityDictionary; importantPartEntity.Update(); ImportantPartEntityList.Add(importantPartEntity); } IsBusy = false; }
private void OnImportCommand() { OpenFileDialog lOpenFile = new OpenFileDialog(); lOpenFile.Filter = "Excel (*.xls)|*.xls"; Dictionary <String, int> lHeaderDictionary = new Dictionary <String, int>(); if (lOpenFile.ShowDialog() == true) { ImportantPartEntityList.Clear(); try { FileStream fs = lOpenFile.File.OpenRead(); Workbook book = Workbook.Open(fs); foreach (KeyValuePair <int, Row> rowPair in book.Worksheets[0].Cells.Rows) { if (rowPair.Key == 0) { try { foreach (KeyValuePair <int, Cell> cellPair in rowPair.Value) { lHeaderDictionary.Add(cellPair.Value.StringValue, cellPair.Key); } } catch (System.Exception ex) { Message.ErrorMessage("表头重复或超出范围!"); break; } continue; } ImportantPartEntity lImportantPartEntity = new ImportantPartEntity(); lImportantPartEntity.ImportantPart = new ProductManager.Web.Model.important_part(); //lImportantPartEntity.ManufactureNumber = ProjectEntity.ManufactureNumber; int lManufactureNumberColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("生产令号", out lManufactureNumberColumn) && -1 != lManufactureNumberColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lManufactureNumberColumn))) { lImportantPartEntity.ManufactureNumber = cell.StringValue; ProjectEntity projectEntityTemp; if (!ProjectEntityDictionary.TryGetValue(lImportantPartEntity.ManufactureNumber, out projectEntityTemp)) { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中没有生产令号:" + lImportantPartEntity.ManufactureNumber); lNotifyWindow.Show(); return; } } else { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中没有生产令号:" + lImportantPartEntity.ManufactureNumber); lNotifyWindow.Show(); return; } } int lImportPartNameColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("主要部件名称", out lImportPartNameColumn) && -1 != lManufactureNumberColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lImportPartNameColumn))) { lImportantPartEntity.ImportantPartName = cell.StringValue; } } int lProjectNameColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("厂家", out lProjectNameColumn) && -1 != lProjectNameColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lProjectNameColumn))) { lImportantPartEntity.ImportantPartManufacturers = cell.StringValue; } } int lModelNumberColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("到货时间", out lModelNumberColumn) && -1 != lModelNumberColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lModelNumberColumn))) { lImportantPartEntity.AriveTime = cell.DateTimeValue; } } //备注 int lRemarkColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("备注", out lRemarkColumn) && -1 != lRemarkColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lRemarkColumn))) { lImportantPartEntity.Note = cell.StringValue; } } App app = Application.Current as App; lImportantPartEntity.AriveUserId = app.UserInfo.UserID; lImportantPartEntity.AriveInputTime = DateTime.Now; lImportantPartEntity.UserEntityDictionary = DictionaryUser; lImportantPartEntity.DUpdate(); ImportantPartEntityList.Add(lImportantPartEntity); //ProductContext.projects.Add(lProjectEntity.Project); } } catch (System.Exception ex) { Message.ErrorMessage(ex.Message); } } }