SVN-Revision: r403
This commit is contained in:
wyf
2025-03-26 11:34:40 +00:00
parent a14d20e387
commit 93e9320282
+22 -22
View File
@@ -67,6 +67,28 @@ namespace Lskj.PubBomImport
FrmBillInfo frmBillInfo = new FrmBillInfo(); FrmBillInfo frmBillInfo = new FrmBillInfo();
DataTable parentTable = ExcelToDatatable(parentInfo.FullName, Model, "", 5); DataTable parentTable = ExcelToDatatable(parentInfo.FullName, Model, "", 5);
parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "")).ToList().CopyToDataTable(); parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "")).ToList().CopyToDataTable();
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow dataRow in parentTable.Rows)
{
string code = (dataRow["图号"] + "").Trim();
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;");
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
}
frmBillInfo.OnControlSourceBind += (s, args) =>
{
Task task = new Task(() =>
{
try
{
SetProcessBar(0, 0);
SetProcessMsg($"正在导入:{Path.GetFileName(parentInfo.FullName)}");
DataTable childTable = new DataTable(); DataTable childTable = new DataTable();
foreach (GridColumn gridColumn in frmBillInfo.GcMainView.Columns) foreach (GridColumn gridColumn in frmBillInfo.GcMainView.Columns)
{ {
@@ -90,28 +112,6 @@ namespace Lskj.PubBomImport
childTable.Rows.Add(childRow); childTable.Rows.Add(childRow);
} }
} }
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow dataRow in parentTable.Rows)
{
string code = (dataRow["图号"] + "").Trim();
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;");
}
}
if (!string.IsNullOrEmpty(stringBuilder.ToString()))
{
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
}
frmBillInfo.OnControlSourceBind += (s, args) =>
{
Task task = new Task(() =>
{
try
{
SetProcessBar(0, 0);
SetProcessMsg($"正在导入:{Path.GetFileName(parentInfo.FullName)}");
SetProcessBar(20, 0); SetProcessBar(20, 0);
frmBillInfo.GcMainView.GridControl.DataSource = childTable; frmBillInfo.GcMainView.GridControl.DataSource = childTable;
SetProcessBar(40, 0); SetProcessBar(40, 0);