private ImportMessageModel BarcodeInfo_FormatRow(DataRow row, Mes_Tra_SourceBarcode itemObj, int rowIndex) { ImportMessageModel errorObj = null; try { itemObj.Barcode = TConvertHelper.FormatDBString(row["条码"]); if (string.IsNullOrEmpty(itemObj.Barcode)) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "条码不能为空" }); } } catch (Exception ex) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = ex.Message }); } return(errorObj); }
private ImportMessageModel TecProcessBom_FormatRow(DataRow row, Mes_Tec_ProcessBomItem itemObj, int rowIndex) { ImportMessageModel errorObj = null; try { //导入样品 itemObj.MaterialProNo = TConvertHelper.FormatDBString(row["产品编码"]); itemObj.Version = TConvertHelper.FormatDBString(row["版本"]); itemObj.ProcessName = TConvertHelper.FormatDBString(row["工艺"]); itemObj.SubMaterialProNo = TConvertHelper.FormatDBString(row["物料编码"]); itemObj.Num = TConvertHelper.FormatDBInt(row["数量"]); itemObj.Memo = TConvertHelper.FormatDBString(row["备注"]); itemObj.CreatedTime = DateTime.Now; if (string.IsNullOrEmpty(itemObj.MaterialProNo) || string.IsNullOrEmpty(itemObj.Version)) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "产品编码、版本不能为空" }); } if (string.IsNullOrEmpty(itemObj.SubMaterialProNo)) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "物料编码不能为空" }); } if (string.IsNullOrEmpty(itemObj.ProcessName)) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "工艺不能为空" }); } if (itemObj.Num <= 0) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "数量不能为空" }); } } catch (Exception ex) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = ex.Message }); } return(errorObj); }
private ImportMessageModel ProductInfo_FormatRow(DataRow row, Mes_Tec_ProductInfo itemObj, int rowIndex) { ImportMessageModel errorObj = null; try { //导入样品 string sTemp = ""; itemObj.MaterialProNo = TConvertHelper.FormatDBString(row["物料编码"]); itemObj.MaterialCode = TConvertHelper.FormatDBString(row["物料名称"]); sTemp = TConvertHelper.FormatDBString(row["物料分类"]); if (!string.IsNullOrEmpty(sTemp)) { itemObj.MaterialClass = StatusHelper.GetStatusByDescription <MaterialClassStatus>(sTemp); } sTemp = TConvertHelper.FormatDBString(row["批次属性"]); if (!string.IsNullOrEmpty(sTemp)) { itemObj.TraceProperty = TConvertHelper.FormatDBInt(StatusHelper.GetStatusByDescription <MaterialClassStatus>(sTemp)); } itemObj.MaterialSize = TConvertHelper.FormatDBString(row["规格尺寸"]); itemObj.Unit = TConvertHelper.FormatDBString(row["单位"]); itemObj.PackNumber = TConvertHelper.FormatDBInt(row["每箱数量"]); itemObj.Memo = TConvertHelper.FormatDBString(row["备注"]); //itemObj.CreatedTime = DateTime.Now; if (string.IsNullOrEmpty(itemObj.MaterialProNo) || string.IsNullOrEmpty(itemObj.MaterialCode)) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "物料编码、物料名称不能为空" }); } } catch (Exception ex) { return(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = ex.Message }); } return(errorObj); }
private IList <ImportMessageModel> Import_BarcodeInfo(DataTable dtData) { IList <ImportMessageModel> resultList = new List <ImportMessageModel>(); //提示用户导入消息有错,但不影响数据导入 IList <ImportMessageModel> msgList = new List <ImportMessageModel>(); List <Mes_Tra_SourceBarcode> dataList = new List <Mes_Tra_SourceBarcode>(); int rowIndex = 0;//第1行是行头 DateTime time = DateTime.Now; ImportMessageModel errorObj = null; string batchNo = DateTime.Now.ToString("yyMMddHHmmss"); if (dtData != null && dtData.Rows.Count > 0) { Mes_Tra_SourceBarcode itemObj = null; foreach (DataRow row in dtData.Rows) { rowIndex++; itemObj = new Mes_Tra_SourceBarcode(); itemObj.CreatedTime = time; itemObj.Creater = curUserId; itemObj.PackSN = batchNo; //存样品信息 errorObj = BarcodeInfo_FormatRow(row, itemObj, rowIndex); if (errorObj != null) //记录行错误信息 { resultList.Add(errorObj); continue; } //检测条码是否重复 if (SourceBarcodeDao.Instance.IsExist(itemObj.Barcode)) { resultList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("条码【{0}】已经存在", itemObj.Barcode) }); } if (dataList.Exists(p => p.Barcode == itemObj.Barcode)) { resultList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("条码【{0}】重复导入", itemObj.Barcode) }); } dataList.Add(itemObj); } } //如果校验有错误,直接返回错误信息 if (resultList.Count > 0) { return(resultList); } //2.校验成功执行导入 SourceBarcodeDao.Instance.Import(dataList, resultList); if (resultList.Count == 0) { resultList.Add(new ImportMessageModel { RowData = "导入成功", RowMessage = "数据已成功导入" }); } return(resultList); }
private IList <ImportMessageModel> Import_ProductInfo(DataTable dtData) { IList <ImportMessageModel> resultList = new List <ImportMessageModel>(); //提示用户导入消息有错,但不影响数据导入 IList <ImportMessageModel> msgList = new List <ImportMessageModel>(); List <Mes_Tec_ProductInfo> productAllList = null; List <Mes_Tec_ProductInfo> dataList = new List <Mes_Tec_ProductInfo>(); int rowIndex = 0; //第1行是行头 DateTime time = DateTime.Now; ImportMessageModel errorObj = null; if (dtData != null && dtData.Rows.Count > 0) { productAllList = MesTecProductInfoDao.Instance.FindAll <Mes_Tec_ProductInfo>(); Mes_Tec_ProductInfo productObj = null; foreach (DataRow row in dtData.Rows) { rowIndex++; productObj = new Mes_Tec_ProductInfo(); productObj.CreatedTime = time; productObj.Creater = curUserId; //存样品信息 errorObj = ProductInfo_FormatRow(row, productObj, rowIndex); if (errorObj != null) //记录行错误信息 { resultList.Add(errorObj); continue; } //检测物料编码是否重复,不允许重复 if (productAllList.Exists(p => p.MaterialProNo == productObj.MaterialProNo)) { resultList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("物料编码【{0}】已经存在", productObj.MaterialProNo) }); } if (dataList.Exists(p => p.MaterialProNo == productObj.MaterialProNo)) { resultList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("物料编码【{0}】重复导入", productObj.MaterialProNo) }); } dataList.Add(productObj); } } //如果校验有错误,直接返回错误信息 if (resultList.Count > 0) { return(resultList); } //2.校验成功执行导入 MesTecProductInfoDao.Instance.Import(dataList, resultList); if (resultList.Count == 0) { resultList.Add(new ImportMessageModel { RowData = "导入成功", RowMessage = "数据已成功导入" }); } return(resultList); }
private IList <ImportMessageModel> Import_TecProcessBom(DataTable dtData) { IList <ImportMessageModel> resultList = new List <ImportMessageModel>(); //提示用户导入消息有错,但不影响数据导入 IList <ImportMessageModel> msgList = new List <ImportMessageModel>(); List <Mes_Tec_ProcessBom> bomList = new List <Mes_Tec_ProcessBom>(); List <Mes_Tec_ProcessBomItem> dataList = new List <Mes_Tec_ProcessBomItem>(); List <Mes_Tec_Process> processList = null; List <Mes_Tec_ProductInfo> productList = null; int rowIndex = 0; //第1行是行头 DateTime time = DateTime.Now; ImportMessageModel errorObj = null; if (dtData != null && dtData.Rows.Count > 0) { Mes_Tec_ProcessBom bomObj = null; Mes_Tec_ProcessBomItem bomItemObj = null; Mes_Tec_Process processObj = null; Mes_Tec_ProductInfo productObj = null; processList = MesTecProcessDao.Instance.FindAll <Mes_Tec_Process>(); productList = MesTecProductInfoDao.Instance.FindAll <Mes_Tec_ProductInfo>(); foreach (DataRow row in dtData.Rows) { rowIndex++; bomItemObj = new Mes_Tec_ProcessBomItem(); bomItemObj.CreatedTime = time; bomItemObj.Creater = curUserId; //存样品信息 errorObj = TecProcessBom_FormatRow(row, bomItemObj, rowIndex); if (errorObj != null) //记录行错误信息 { resultList.Add(errorObj); continue; } processObj = processList.Where(p => p.Name == bomItemObj.ProcessName && p.RecordStatus == 1).FirstOrDefault(); if (processObj == null) { msgList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("工艺【{0}】不存在", bomItemObj.ProcessName) }); } else { bomItemObj.ProcessID = processObj.ID; } productObj = productList.Where(p => p.MaterialProNo == bomItemObj.MaterialProNo).FirstOrDefault(); if (productObj == null) { msgList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("产品编码【{0}】不存在", bomItemObj.MaterialProNo) }); } else { bomItemObj.MaterialCode = productObj.MaterialCode; if (!bomList.Exists(p => p.MaterialProNo == bomItemObj.MaterialProNo && p.Version == bomItemObj.Version)) { bomObj = new Mes_Tec_ProcessBom(); bomObj.MaterialProNo = bomItemObj.MaterialProNo; bomObj.MaterialCode = bomItemObj.MaterialCode; bomObj.Version = bomItemObj.Version; bomObj.CreatedTime = time; bomObj.Creater = curUserId; bomList.Add(bomObj); } } productObj = productList.Where(p => p.MaterialProNo == bomItemObj.SubMaterialProNo).First(); if (productObj == null) { msgList.Add(new ImportMessageModel() { RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("物料编码【{0}】不存在", bomItemObj.MaterialProNo) }); } else { bomItemObj.SubMaterialCode = productObj.MaterialCode; } dataList.Add(bomItemObj); } } //如果校验有错误,直接返回错误信息 if (resultList.Count > 0) { return(resultList); } //2.校验成功执行导入 MesTecProcessBomDao.Instance.Import(bomList, dataList, resultList); if (resultList.Count == 0) { resultList.Add(new ImportMessageModel { RowData = "导入成功", RowMessage = "数据已成功导入" }); } return(resultList); }