SVN-Revision: r469
This commit is contained in:
wyf
2025-04-10 02:56:37 +00:00
parent 62a5bc8f66
commit ed3970aba7
2 changed files with 66 additions and 36 deletions
+46 -14
View File
@@ -186,24 +186,11 @@ namespace Lskj.PubBomImport
}
else if (Model.ShowType.Equals("3"))
{
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
if (StaticControl.RightMenuGridView.Tag is Dictionary<string, string> filesDic)
{
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
frmProgress.Model = Model;
frmProgress.ImportTimer.Tick += (ts, te) =>
{
frmProgress.ImportTimer.Enabled = false;
frmProgress.StartImportInQDFile(sourceTable, filesDic);
};
frmProgress.ImportTimer.Enabled = true;
DialogResult dialogResult = frmProgress.ShowDialog();
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
ShowType = Model.ShowType,
AfterBomFieldName = Model.AfterBomFieldName,
CanSave = dialogResult == DialogResult.OK
CanSave = true
};
FormDialogModel dialogModel = new FormDialogModel()
{
@@ -212,8 +199,53 @@ namespace Lskj.PubBomImport
ReturnTag = bomImpRtnModel
};
this.Tag = dialogModel;
if (StaticControl.RightMenuGridView.Tag is Dictionary<DataRow, string> filesDic)
{
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
List<DataRow> selectRows = new List<DataRow>();
foreach (DataRow sourceRow in sourceTable.Rows)
{
if (sourceRow.RowState == DataRowState.Deleted)
{
continue;
}
string fileName = sourceRow[Model.AfterBomFieldName] + "";
string dirPath = filesDic.ContainsKey(sourceRow) ? filesDic[sourceRow] : "";
FileInfo parentInfo = null;
if (string.IsNullOrEmpty(dirPath))
{
continue;
}
parentInfo = new FileInfo(dirPath);
if (parentInfo != null && (parentInfo.Name.Trim().StartsWith("QD") || parentInfo.Name.Trim().StartsWith("ZZQD")))
{
selectRows.Add(sourceRow);
}
}
if (selectRows.Count > 0)
{
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
frmProgress.Model = Model;
frmProgress.ImportTimer.Tick += (ts, te) =>
{
frmProgress.ImportTimer.Enabled = false;
frmProgress.StartImportInQDFile(selectRows, filesDic);
};
frmProgress.ImportTimer.Enabled = true;
DialogResult dialogResult = frmProgress.ShowDialog();
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
frmProgress.Dispose();
}
else
{
this.Close();
}
}
else
{
this.Close();
}
}
}
//else if (Model.ShowType.Equals("4"))//禁用
+11 -13
View File
@@ -505,18 +505,18 @@ namespace Lskj.PubBomImport
/// 开始导入3
/// </summary>
/// <param name="dirPaths"></param>
public void StartImportInQDFile(DataTable sourceTable, Dictionary<string, string> filesDic)
public void StartImportInQDFile(List<DataRow> selectRows, Dictionary<DataRow, string> filesDic)
{
try
{
foreach (DataRow sourceRow in sourceTable.Rows)
foreach (DataRow sourceRow in selectRows)
{
if (sourceRow.RowState == DataRowState.Deleted)
{
continue;
}
string fileName = sourceRow[Model.AfterBomFieldName] + "";
string dirPath = filesDic.ContainsKey(fileName) ? filesDic[fileName] : "";
string dirPath = filesDic.ContainsKey(sourceRow) ? filesDic[sourceRow] : "";
FileInfo parentInfo = null;
if (string.IsNullOrEmpty(dirPath))
{
@@ -553,17 +553,17 @@ namespace Lskj.PubBomImport
{
try
{
foreach (DataRow sourceRow in sourceTable.Rows)
foreach (DataRow sourceRow in selectRows)
{
if (sourceRow.RowState == DataRowState.Deleted)
{
continue;
}
int childIndex = sourceTable.Rows.IndexOf(sourceRow);
int allCount = (int)((decimal)(childIndex) / (sourceTable.Rows.Count) * 100);
int finishCount = (int)((decimal)(1 + childIndex) / (sourceTable.Rows.Count) * 100);
int childIndex = selectRows.IndexOf(sourceRow);
int allCount = (int)((decimal)(childIndex) / (selectRows.Count) * 100);
int finishCount = (int)((decimal)(1 + childIndex) / (selectRows.Count) * 100);
string fileName = sourceRow[Model.AfterBomFieldName] + "";
string dirPath = filesDic.ContainsKey(fileName) ? filesDic[fileName] : "";
string dirPath = filesDic.ContainsKey(sourceRow) ? filesDic[sourceRow] : "";
FileInfo parentInfo = null;
if (string.IsNullOrEmpty(dirPath))
{
@@ -652,7 +652,7 @@ namespace Lskj.PubBomImport
//上传文件
bool isUpload = UploadFile(childInfo.FullName, billNo, out string msg);
SetProcessBar(100, finishCount);
SetProcessLabelAllMsg($"总进度:{childIndex + 1}/{sourceTable.Rows.Count }");
SetProcessLabelAllMsg($"总进度:{childIndex + 1}/{selectRows.Count }");
}
else
{
@@ -667,10 +667,7 @@ namespace Lskj.PubBomImport
}
else
{
MessageUtil.Show("不是QD或ZZQD文件");
this.DialogResult = DialogResult.Cancel;
Close();
ImportTimer?.Dispose();
throw new Exception($"{parentInfo.Name}不是QD或ZZQD文件");
}
}
else
@@ -1193,5 +1190,6 @@ namespace Lskj.PubBomImport
catch (Exception ex)
{
returnMsg = ex.Message;
throw new Exception($"文件{Path.GetFileName(filePath)}上传失败\r\n{ex.Message}");
isUpload = false;