SVN r659
SVN-Revision: r659
This commit is contained in:
@@ -64,7 +64,7 @@ namespace Lskj.PubBomImport
|
|||||||
private void FrmMain_Load(object sender, EventArgs e)
|
private void FrmMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int.TryParse(Model.ShowType, out int showTypeValue);
|
int.TryParse(Model.ShowType, out int showTypeValue);
|
||||||
bool showType = Model != null && showTypeValue > 0 && !ERPInfo.Instance.UserName.Equals("管理员");
|
bool showType = Model != null && showTypeValue >= 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (showType)
|
if (showType)
|
||||||
@@ -80,7 +80,7 @@ namespace Lskj.PubBomImport
|
|||||||
InitGridColumns();
|
InitGridColumns();
|
||||||
InitMulitControl();
|
InitMulitControl();
|
||||||
InitDataSource();
|
InitDataSource();
|
||||||
if (showTypeValue == 0 || showTypeValue == 2 || showTypeValue == 3 || showTypeValue == 33 || showTypeValue == 4 || showTypeValue == 44 || showTypeValue == 5 || showTypeValue == 55 || (showTypeValue > 0 && showType))
|
if (showType)
|
||||||
{
|
{
|
||||||
OnBtnImportClick(null, null);
|
OnBtnImportClick(null, null);
|
||||||
}
|
}
|
||||||
@@ -260,32 +260,66 @@ namespace Lskj.PubBomImport
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else if (Model.ShowType.Equals("1"))
|
else if (Model.ShowType.Equals("1"))//新增多个其它文件,无版次版本验证,关联到物料编码下
|
||||||
//{
|
{
|
||||||
// FolderBrowserDialog dialog = new FolderBrowserDialog();
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
// dialog.SelectedPath = Properties.Settings.Default.LastSelectFolder;
|
{
|
||||||
// dialog.Description = "选择导入文件夹";
|
ShowType = Model.ShowType,
|
||||||
// DialogResult dialogResult = dialog.ShowDialog();
|
AfterBomFieldName = Model.AfterBomFieldName,
|
||||||
// if (dialogResult == DialogResult.OK)
|
CanSave = true
|
||||||
// {
|
};
|
||||||
// Properties.Settings.Default.LastSelectFolder = dialog.SelectedPath;
|
FormDialogModel dialogModel = new FormDialogModel()
|
||||||
// string dirPath = dialog.SelectedPath;
|
{
|
||||||
// FrmProgress frmProgress = new FrmProgress();
|
DialogDllName = "Lskj.PubBomImport.dll",
|
||||||
// frmProgress.frmMain = this;
|
PubDialogType = DialogType.PubAddRecord,
|
||||||
// frmProgress.ImportTimer.Tick += (ts, te) =>
|
ReturnTag = bomImpRtnModel
|
||||||
// {
|
};
|
||||||
// frmProgress.ImportTimer.Enabled = false;
|
this.Tag = dialogModel;
|
||||||
// frmProgress.StartImportInDir(dirPath);
|
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
|
||||||
// };
|
if (sourceTable.Columns.Contains("BomFieldNameDir"))
|
||||||
// frmProgress.ImportTimer.Enabled = true;
|
{
|
||||||
// frmProgress.ShowDialog();
|
List<DataRow> selectRows = new List<DataRow>();
|
||||||
// frmProgress.Dispose();
|
foreach (DataRow sourceRow in sourceTable.Rows)
|
||||||
// }
|
{
|
||||||
// else
|
if (sourceRow.RowState == DataRowState.Deleted)
|
||||||
// {
|
{
|
||||||
// this.Close();
|
continue;
|
||||||
// }
|
}
|
||||||
//}
|
string fileName = sourceRow[Model.AfterBomFieldName] + "";
|
||||||
|
string dirPath = sourceRow["BomFieldNameDir"] + "";
|
||||||
|
FileInfo parentInfo = null;
|
||||||
|
if (string.IsNullOrEmpty(dirPath))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
parentInfo = new FileInfo(dirPath);
|
||||||
|
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.StartImportInOtherFiles(selectRows);
|
||||||
|
};
|
||||||
|
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("2"))//一级BOM上传
|
else if (Model.ShowType.Equals("2"))//一级BOM上传
|
||||||
{
|
{
|
||||||
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
|
|||||||
@@ -260,6 +260,133 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Bom结构补充,新增其它文件,无版本控制
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPaths"></param>
|
||||||
|
public void StartImportInOtherFiles(List<DataRow> selectRows)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int execOrder = 1;
|
||||||
|
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||||
|
foreach (DataRow selectRow in selectRows)
|
||||||
|
{
|
||||||
|
string productId = selectRow["BomMxMainProduct"] + "";
|
||||||
|
if (string.IsNullOrEmpty(productId))
|
||||||
|
{
|
||||||
|
throw new Exception($"物料编码不能为空");
|
||||||
|
}
|
||||||
|
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||||
|
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||||
|
FileInfo fileInfo = new FileInfo(dirPath);
|
||||||
|
if (fileInfo != null)
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
if (fileNameWithoutExtension.StartsWith("ZZQD"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充ZZQD文件{fileNameWithoutExtension}");
|
||||||
|
}
|
||||||
|
else if (fileNameWithoutExtension.StartsWith("MX"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充MX文件{fileNameWithoutExtension}");
|
||||||
|
}
|
||||||
|
else if (fileNameWithoutExtension.StartsWith("QD"))
|
||||||
|
{
|
||||||
|
throw new Exception($"不允许补充QD文件{fileNameWithoutExtension}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '010106' and sname = '{fileNameWithoutExtension}'");
|
||||||
|
if (filetable.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}的附件已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frmBillInfo.OnControlSourceBind += (s, args) =>
|
||||||
|
{
|
||||||
|
Task task = new Task(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int.TryParse(Model.FirstRowIndex, out int index);
|
||||||
|
frmMain.FirstRowIndex = index;
|
||||||
|
foreach (DataRow selectRow in selectRows)
|
||||||
|
{
|
||||||
|
string productId = selectRow["BomMxMainProduct"] + "";
|
||||||
|
int childIndex = selectRows.IndexOf(selectRow);
|
||||||
|
int nowCount = 1 + childIndex;
|
||||||
|
int allCount = (int)((decimal)(1 + childIndex) / (selectRows.Count + 1) * 100);
|
||||||
|
int finishCount = (int)((decimal)(1 + nowCount) / (selectRows.Count + 1) * 100);
|
||||||
|
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||||
|
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||||
|
FileInfo fileInfo = new FileInfo(dirPath);
|
||||||
|
if (fileInfo != null)
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
SetProcessBar(0, allCount);
|
||||||
|
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, "010106", out string msg, out string uploadFileId);
|
||||||
|
if (!isUpload)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
||||||
|
}
|
||||||
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (selectRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||||
|
{
|
||||||
|
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||||
|
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
SetProcessBar(100, finishCount);
|
||||||
|
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
ImportTimer?.Dispose();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageUtil.Show(ex.Message);
|
||||||
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
ImportTimer?.Dispose();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
task.Start();
|
||||||
|
};
|
||||||
|
frmBillInfo.OnLoad(Model);
|
||||||
|
frmMain.ParentView = frmBillInfo.GcMainView;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageUtil.Show(ex.Message);
|
||||||
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
ImportTimer?.Dispose();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 修改单个文件
|
/// 修改单个文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dirPaths"></param>
|
/// <param name="dirPaths"></param>
|
||||||
@@ -1256,6 +1383,13 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||||
}
|
}
|
||||||
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (childInfoRow.Table.Columns.Contains("qms_laddf_uploadtag"))
|
||||||
|
{
|
||||||
|
childInfoRow["qms_laddf_uploadtag"] = 1;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
@@ -1289,6 +1423,13 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||||
}
|
}
|
||||||
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (childInfoRow.Table.Columns.Contains("qms_laddf_uploadtag"))
|
||||||
|
{
|
||||||
|
childInfoRow["qms_laddf_uploadtag"] = 1;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -1361,6 +1502,13 @@ namespace Lskj.PubBomImport
|
|||||||
{
|
{
|
||||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||||
}
|
}
|
||||||
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (childInfoRow.Table.Columns.Contains("qms_laddf_uploadtag"))
|
||||||
|
{
|
||||||
|
childInfoRow["qms_laddf_uploadtag"] = 1;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user