SVN r685
SVN-Revision: r685
This commit is contained in:
@@ -713,6 +713,66 @@ namespace Lskj.PubBomImport
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Model.ShowType.Equals("8"))//修改多个版次LX-文件,新增附件
|
||||||
|
{
|
||||||
|
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||||
|
{
|
||||||
|
ShowType = Model.ShowType,
|
||||||
|
AfterBomFieldName = Model.AfterBomFieldName,
|
||||||
|
CanSave = true
|
||||||
|
};
|
||||||
|
FormDialogModel dialogModel = new FormDialogModel()
|
||||||
|
{
|
||||||
|
DialogDllName = "Lskj.PubBomImport.dll",
|
||||||
|
PubDialogType = DialogType.PubAddRecord,
|
||||||
|
ReturnTag = bomImpRtnModel
|
||||||
|
};
|
||||||
|
this.Tag = dialogModel;
|
||||||
|
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
|
||||||
|
if (sourceTable.Columns.Contains("BomFieldNameDir"))
|
||||||
|
{
|
||||||
|
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 = 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.StartUpdateInOtherBBFiles(selectRows);
|
||||||
|
};
|
||||||
|
frmProgress.ImportTimer.Enabled = true;
|
||||||
|
DialogResult dialogResult = frmProgress.ShowDialog();
|
||||||
|
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
|
||||||
|
frmProgress.Dispose();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -313,6 +313,10 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!bb.Equals("SA"))
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileInfo.Name}\r\n版本不为SA不允许新增,请进行修改");
|
||||||
|
}
|
||||||
if (bc > 0)
|
if (bc > 0)
|
||||||
{
|
{
|
||||||
throw new Exception($"{fileInfo.Name}\r\n不为0的版次不允许新增,请进行修改");
|
throw new Exception($"{fileInfo.Name}\r\n不为0的版次不允许新增,请进行修改");
|
||||||
@@ -326,7 +330,7 @@ namespace Lskj.PubBomImport
|
|||||||
maxfileRowDic[fileInfo.Name] = maxRow;
|
maxfileRowDic[fileInfo.Name] = maxRow;
|
||||||
if (maxRow != null)//如果存在则不允许上传
|
if (maxRow != null)//如果存在则不允许上传
|
||||||
{
|
{
|
||||||
throw new Exception("已存在附件无法新增");
|
throw new Exception("已存在该版本附件无法新增");
|
||||||
//int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
//int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
||||||
//int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
//int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
||||||
//if (newbb > oldbb)
|
//if (newbb > oldbb)
|
||||||
@@ -553,6 +557,223 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 变更LX-版本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPaths"></param>
|
||||||
|
public void StartUpdateInOtherBBFiles(List<DataRow> selectRows)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int execOrder = 1;
|
||||||
|
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||||
|
string bomOtherAddMode = selectRows[0]["qms_laddf_mode"] + "";
|
||||||
|
string speciesno = selectRows[0]["BomAddSpeciesNo"] + "";
|
||||||
|
string oldProductId = selectRows[0]["BomAddOldProductId"] + "";
|
||||||
|
GridControlEx gridControlEx = null;
|
||||||
|
if (StaticControl.BomUnionPage != null && StaticControl.BomUnionPage.Tag is GridControlEx gridDetailControl)
|
||||||
|
{
|
||||||
|
gridControlEx = gridDetailControl;
|
||||||
|
}
|
||||||
|
DataTable dataTable = gridControlEx.GridControl.DataSourceTable();
|
||||||
|
int[] bomRowIndexs = gridControlEx.GridView.GetSelectedRows();
|
||||||
|
//if (bomRowIndexs.Count() <= 0)
|
||||||
|
//{
|
||||||
|
// throw new Exception("请选择需要变更的Bom");
|
||||||
|
//}
|
||||||
|
if (string.IsNullOrEmpty(oldProductId))
|
||||||
|
{
|
||||||
|
throw new Exception("无旧物料编码");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(bomOtherAddMode))
|
||||||
|
{
|
||||||
|
throw new Exception("未选择上传模式");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(speciesno))
|
||||||
|
{
|
||||||
|
throw new Exception("未选择文件分类");
|
||||||
|
}
|
||||||
|
if (bomOtherAddMode.Equals("9040"))//有规则
|
||||||
|
{
|
||||||
|
Dictionary<string, DataRow> maxfileRowDic = new Dictionary<string, DataRow>();
|
||||||
|
foreach (DataRow selectRow in selectRows)
|
||||||
|
{
|
||||||
|
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||||
|
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||||
|
FileInfo fileInfo = new FileInfo(dirPath);
|
||||||
|
if (fileInfo != null)
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
bool isMatch = GetOtherFileCodeInfo(fileInfo.Name, out string code, out string spec, out string name, out string extension, out string bb, out int bc);
|
||||||
|
if (!isMatch)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileInfo.Name}\r\n文件名不符合规则");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(code))
|
||||||
|
{
|
||||||
|
throw new Exception($"编码解析为空");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(spec))
|
||||||
|
{
|
||||||
|
throw new Exception($"规格解析为空");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
throw new Exception($"名称解析为空");
|
||||||
|
}
|
||||||
|
if (!fileNameWithoutExtension.StartsWith("LX"))
|
||||||
|
{
|
||||||
|
throw new Exception($"文件{fileNameWithoutExtension}名称不符合规则\r\n不以LX开头");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!oldProductId.Trim().Equals(code))
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileInfo.Name}\r\n编码与文件名不匹配");
|
||||||
|
}
|
||||||
|
if (bc > 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileInfo.Name}\r\n不为0的版次不允许新增,请进行修改");
|
||||||
|
}
|
||||||
|
DataRow productRow = BaseImpl.GetDataRowResult($"select ProductId from p_productTab where ProductId = '{code}'");
|
||||||
|
if (productRow == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"物料编码{code}不存在,无法新增");
|
||||||
|
}
|
||||||
|
DataRow maxRow = BaseImpl.GetDataRowResult($"exec dbo.p_CheckLxFileRevision N'{fileInfo.Name}','{speciesno}';");
|
||||||
|
maxfileRowDic[fileInfo.Name] = maxRow;
|
||||||
|
if (maxRow != null)//如果存在则不允许上传
|
||||||
|
{
|
||||||
|
throw new Exception("已存在该版本附件无法新增");
|
||||||
|
//int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
||||||
|
//int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
||||||
|
//if (newbb > oldbb)
|
||||||
|
//{
|
||||||
|
// throw new Exception($"{fileInfo.Name}\r\n版本号大于最大版本号{oldbb},请进行修改");
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
DataRow maxRow = maxfileRowDic.ContainsKey(fileInfo.Name) ? maxfileRowDic[fileInfo.Name] : null;
|
||||||
|
string uploadFileId = "";
|
||||||
|
if (maxRow != null)//如果存在则不允许上传
|
||||||
|
{
|
||||||
|
throw new Exception("已存在该版本附件无法新增");
|
||||||
|
//uploadFileId = maxRow["fileid"] + "";
|
||||||
|
//int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
||||||
|
//int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
||||||
|
//if (newbb > oldbb)
|
||||||
|
//{
|
||||||
|
// throw new Exception($"{fileInfo.Name}\r\n版本号大于最大版本号,请进行修改");
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||||
|
GetOtherFileCodeInfo(fileInfo.Name, out string code, out string spec, out string name, out string extension, out string bb, out int bc);
|
||||||
|
SetProcessBar(0, allCount);
|
||||||
|
bool isUpload = UploadFileToAudit(fileInfo.FullName, code, speciesno, out string msg, out uploadFileId);
|
||||||
|
if (!isUpload)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
||||||
|
}
|
||||||
|
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (selectRow.Table.Columns.Contains("qms_laddf_uploadtag"))
|
||||||
|
{
|
||||||
|
selectRow["qms_laddf_uploadtag"] = 1;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
SetProcessBar(100, finishCount);
|
||||||
|
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName}的文件不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (int bomRowIndex in bomRowIndexs)
|
||||||
|
{
|
||||||
|
DataRow dataRow = gridControlEx.GridView.GetDataRow(bomRowIndex);
|
||||||
|
string sql = $@"insert bom_bgRwTab (productid,appellation,spec,yproductid,yappellation,yspec,xdopname,xddate,comid)
|
||||||
|
select '{dataRow["productid"] + ""}','{dataRow["appellation"] + ""}','{dataRow["spec"] + ""}',productid,appellation,spec,'{ERPInfo.Instance.UserName}',getdate(),0
|
||||||
|
from p_producttab where productid = '{dataRow["Yproductid"] + ""}'
|
||||||
|
and '{dataRow["productid"] + ""}' not in(select productid from bom_bgRwTab where isnull(comid, 0) = 0)";
|
||||||
|
SqlHelper.ExecuteNonQuery(sql);
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("仅支持有规则附件");
|
||||||
|
}
|
||||||
|
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>
|
||||||
@@ -813,7 +1034,7 @@ namespace Lskj.PubBomImport
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//如果符合规则,则直接改变当前编码下的文件
|
//如果符合规则,则直接改变当前编码下的文件
|
||||||
throw new Exception("暂未开启");
|
throw new Exception("只允许更改其它无规则文件");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -879,7 +1100,7 @@ namespace Lskj.PubBomImport
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
throw new Exception("只允许更改其它无规则文件");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user