diff --git a/插件库/Lskj.PubBomImport/FrmBillInfo.cs b/插件库/Lskj.PubBomImport/FrmBillInfo.cs index 6fa1e6d..f972569 100644 --- a/插件库/Lskj.PubBomImport/FrmBillInfo.cs +++ b/插件库/Lskj.PubBomImport/FrmBillInfo.cs @@ -169,11 +169,15 @@ namespace Lskj.PubBomImport { saveResult = true; } + else + { + throw new Exception($"保存Bom失败\r\n{tipMsg}"); + } } } catch (Exception ex) { - MessageUtil.Show(ex.Message); + throw new Exception($"保存Bom失败\r\n{ex.Message}"); } } return saveResult; diff --git a/插件库/Lskj.PubBomImport/FrmMain.cs b/插件库/Lskj.PubBomImport/FrmMain.cs index d6e4b5a..8e4e0be 100644 --- a/插件库/Lskj.PubBomImport/FrmMain.cs +++ b/插件库/Lskj.PubBomImport/FrmMain.cs @@ -707,7 +707,7 @@ namespace Lskj.PubBomImport for (int j = firstRow.FirstCellNum; j < cellCount; j++) { ICell cell = row.GetCell(j); - if (cell.IsMergedCell) + if (cell != null && cell.IsMergedCell) { CellRangeAddress mergrRange = FindMergedRegion(sheet, i, j); if (j == mergrRange.FirstColumn) diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index 1f76814..1bc416c 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -74,7 +74,7 @@ namespace Lskj.PubBomImport if (code.StartsWith("QD") || code.StartsWith("ZZQD")) { stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{dataRow["图号"] + ""}')"); - stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak) values ('{(dataRow["图号"] + "").Replace("'", "''")}','{(dataRow["名称"] + "").Replace("'", "''")}','{(dataRow["备注"] + "").Replace("'", "''")}') end;"); + stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{(dataRow["图号"] + "").Replace("'", "''")}','{(dataRow["名称"] + "").Replace("'", "''")}','{(dataRow["备注"] + "").Replace("'", "''")}','0199') end;"); } } if (!string.IsNullOrEmpty(stringBuilder.ToString())) @@ -142,46 +142,49 @@ namespace Lskj.PubBomImport int.TryParse(dataRow["套数"] + "", out int tamount); string code = (dataRow["图号"] + "").Trim(); FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(code)).FirstOrDefault(); - if (childInfo != null && (code.StartsWith("QD") || code.StartsWith("ZZQD"))) + if (childInfo != null) { - SetProcessBar(0, allCount); - SetProcessMsg($"正在导入:{Path.GetFileName(childInfo.FullName)}"); - DataTable detailTable = new DataTable(); - frmMain.Invoke(new Action(() => + if ((code.StartsWith("QD") || code.StartsWith("ZZQD"))) { - detailTable = frmMain.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true); - })); - foreach (DataRow detailRow in detailTable.Rows) + SetProcessBar(0, allCount); + SetProcessMsg($"正在导入:{Path.GetFileName(childInfo.FullName)}"); + DataTable detailTable = new DataTable(); + frmMain.Invoke(new Action(() => + { + detailTable = frmMain.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true); + })); + foreach (DataRow detailRow in detailTable.Rows) + { + int.TryParse(detailRow["amount"] + "", out int lastAmount); + detailRow["tamount"] = tamount; + detailRow["amount"] = tamount > 0 ? (lastAmount * tamount) + "" : lastAmount + ""; + } + frmBillInfo.GcMainView.GridControl.DataSource = detailTable; + SetProcessBar(20, allCount); + frmBillInfo.InitializeHeader(dataRow, Model.BillMasterSql); + SetProcessBar(40, allCount); + frmBillInfo.BillSave(); + SetProcessBar(60, allCount); + frmBillInfo.OnBillAdd(); + string updateChildVerSql = @"update bom_BillListTab set Ver = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{0}') where Billdocument_Id = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{1}') and ProductId='{0}'"; + SqlHelper.ExecuteNonQuery(string.Format(updateChildVerSql, code, productId)); + SetProcessBar(80, allCount); + isUpload = UploadFile(childInfo.FullName, idValue, out msg); + SetProcessBar(100, finishCount); + SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}"); + } + else { - int.TryParse(detailRow["amount"] + "", out int lastAmount); - detailRow["tamount"] = tamount; - detailRow["amount"] = tamount > 0 ? (lastAmount * tamount) + "" : lastAmount + ""; + isUpload = UploadFile(childInfo.FullName, idValue, out msg); + SetProcessBar(100, finishCount); + SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}"); } - frmBillInfo.GcMainView.GridControl.DataSource = detailTable; - SetProcessBar(20, allCount); - frmBillInfo.InitializeHeader(dataRow, Model.BillMasterSql); - SetProcessBar(40, allCount); - frmBillInfo.BillSave(); - SetProcessBar(60, allCount); - frmBillInfo.OnBillAdd(); - string updateChildVerSql = @"update bom_BillListTab set Ver = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{0}') where Billdocument_Id = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{1}') and ProductId='{0}'"; - SqlHelper.ExecuteNonQuery(string.Format(updateChildVerSql, code, productId)); - SetProcessBar(80, allCount); - isUpload = UploadFile(childInfo.FullName, idValue, out msg); - SetProcessBar(100, finishCount); - SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}"); - } - else - { - isUpload = UploadFile(childInfo.FullName, idValue, out msg); - SetProcessBar(100, finishCount); - SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{parentTable.Rows.Count + 1}"); } } } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageUtil.Show(ex.Message); } finally { @@ -268,7 +271,7 @@ namespace Lskj.PubBomImport if (code.StartsWith("QD") || code.StartsWith("ZZQD")) { stringBuilder.AppendLine($"if not exists (select productid from p_ProductTab where productid = '{dataRow["图号"] + ""}')"); - stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak) values ('{(dataRow["图号"] + "").Replace("'", "''")}','{(dataRow["名称"] + "").Replace("'", "''")}','{(dataRow["备注"] + "").Replace("'", "''")}') end;"); + stringBuilder.AppendLine($"begin insert into p_ProductTab (productid,appellation,bak,SpeciesNo) values ('{(dataRow["图号"] + "").Replace("'", "''")}','{(dataRow["名称"] + "").Replace("'", "''")}','{(dataRow["备注"] + "").Replace("'", "''")}','0199') end;"); } } if (!string.IsNullOrEmpty(stringBuilder.ToString()))