SVN r511
SVN-Revision: r511
This commit is contained in:
@@ -2650,13 +2650,30 @@ namespace Lskj.PubBill
|
|||||||
{
|
{
|
||||||
if (e.DialogModel.ReturnTag != null && e.DialogModel.ReturnTag is BomImpRtnModel impRtnModel)
|
if (e.DialogModel.ReturnTag != null && e.DialogModel.ReturnTag is BomImpRtnModel impRtnModel)
|
||||||
{
|
{
|
||||||
if (impRtnModel.ShowType.Equals("3"))//执行保存
|
if (impRtnModel.ShowType.Equals("3") || impRtnModel.ShowType.Equals("5"))//执行保存
|
||||||
{
|
{
|
||||||
CommonMenu menu = (CommonMenu)sender;
|
CommonMenu menu = (CommonMenu)sender;
|
||||||
menu.issuccess = impRtnModel.CanSave;
|
menu.issuccess = impRtnModel.CanSave;
|
||||||
}
|
}
|
||||||
else if (impRtnModel.ShowType.Equals("0"))//返回文件
|
else if (impRtnModel.ShowType.Equals("0") || impRtnModel.ShowType.Equals("00"))//返回文件
|
||||||
{
|
{
|
||||||
|
ControlModel controlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("物料编码")).FirstOrDefault();
|
||||||
|
if (controlModel == null)
|
||||||
|
{
|
||||||
|
MessageUtil.Show($"物料编码不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string mxProductId = ControlObj.GetControlValue(controlModel);
|
||||||
|
if (string.IsNullOrEmpty(mxProductId))
|
||||||
|
{
|
||||||
|
MessageUtil.Show($"物料编码必填");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (impRtnModel.FileNames.Where(n => Path.GetFileName(n).Trim().StartsWith("MX")).Count() == 0)
|
||||||
|
{
|
||||||
|
MessageUtil.Show($"不存在MX文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
DataTable sourceTable = gcMain.gridControl.DataSourceTable();
|
DataTable sourceTable = gcMain.gridControl.DataSourceTable();
|
||||||
if (sourceTable != null && impRtnModel.FileNames != null)
|
if (sourceTable != null && impRtnModel.FileNames != null)
|
||||||
{
|
{
|
||||||
@@ -2665,47 +2682,46 @@ namespace Lskj.PubBill
|
|||||||
{
|
{
|
||||||
sourceTable.Columns.Add("BomFieldNameDir");
|
sourceTable.Columns.Add("BomFieldNameDir");
|
||||||
}
|
}
|
||||||
|
if (!sourceTable.Columns.Contains("BomMxMainProduct"))
|
||||||
|
{
|
||||||
|
sourceTable.Columns.Add("BomMxMainProduct");
|
||||||
|
}
|
||||||
DataTable dataTable = new DataTable();
|
DataTable dataTable = new DataTable();
|
||||||
dataTable.Columns.Add(afterBomFieldName);
|
dataTable.Columns.Add(afterBomFieldName);
|
||||||
dataTable.Columns.Add("BomFieldNameDir");
|
dataTable.Columns.Add("BomFieldNameDir");
|
||||||
IEnumerable<DataRow> rowsIEnumerable = sourceTable.Rows.Cast<DataRow>();
|
dataTable.Columns.Add("BomMxMainProduct");
|
||||||
|
IEnumerable<DataRow> rowsIEnumerable = sourceTable.Rows.Cast<DataRow>().Where(n => n.RowState != DataRowState.Deleted);
|
||||||
string namepattern = @"([A-Za-z]+(-[A-Za-z0-9]+)*-\d+(-\d+)*)";
|
string namepattern = @"([A-Za-z]+(-[A-Za-z0-9]+)*-\d+(-\d+)*)";
|
||||||
foreach (string fileName in impRtnModel.FileNames)
|
foreach (string fileName in impRtnModel.FileNames)
|
||||||
{
|
{
|
||||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName).Trim();
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName).Trim();
|
||||||
if (fileNameWithoutExtension.StartsWith("QD") || fileNameWithoutExtension.StartsWith("ZZQD"))
|
//找到code相同的行
|
||||||
|
DataRow selectRow = rowsIEnumerable.Where(n => (n[afterBomFieldName] + "").Trim().Equals(fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||||
|
if (selectRow != null)
|
||||||
{
|
{
|
||||||
Match namematch = Regex.Match(fileNameWithoutExtension, namepattern);
|
MessageUtil.Show($"{fileNameWithoutExtension}已存在,不允许重复创建");
|
||||||
if (namematch.Success)
|
return;
|
||||||
{
|
|
||||||
string code = namematch.Groups[1].Value;
|
|
||||||
if (!string.IsNullOrEmpty(code))
|
|
||||||
{
|
|
||||||
//找到code相同的行
|
|
||||||
DataRow selectRow = rowsIEnumerable.Where(n => (n[afterBomFieldName] + "").Trim().StartsWith(code, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
||||||
if (selectRow != null)
|
|
||||||
{
|
|
||||||
MessageUtil.Show($"{code}已存在,不允许重复创建");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid like '{code}%'");
|
|
||||||
if (productRow != null)
|
|
||||||
{
|
|
||||||
MessageUtil.Show($"{code}已存在,不允许重复创建");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DataRow addRow = dataTable.NewRow();
|
|
||||||
addRow[afterBomFieldName] = fileNameWithoutExtension;
|
|
||||||
addRow["BomFieldNameDir"] = fileName;
|
|
||||||
dataTable.Rows.Add(addRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid like '{code}%'");
|
||||||
|
//if (productRow != null)
|
||||||
|
//{
|
||||||
|
// MessageUtil.Show($"{code}已存在,不允许重复创建");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
DataRow addRow = dataTable.NewRow();
|
||||||
|
addRow[afterBomFieldName] = fileNameWithoutExtension;
|
||||||
|
addRow["BomFieldNameDir"] = fileName;
|
||||||
|
if (fileNameWithoutExtension.StartsWith("MX"))
|
||||||
|
{
|
||||||
|
addRow["BomMxMainProduct"] = mxProductId;
|
||||||
|
}
|
||||||
|
dataTable.Rows.Add(addRow);
|
||||||
}
|
}
|
||||||
foreach (DataRow item in dataTable.Rows)
|
foreach (DataRow item in dataTable.Rows)
|
||||||
{
|
{
|
||||||
DataRow sourceRow = this.AddRowToGridView(item, true);
|
DataRow sourceRow = this.AddRowToGridView(item, true);
|
||||||
sourceRow["BomFieldNameDir"] = item["BomFieldNameDir"] + "";
|
sourceRow["BomFieldNameDir"] = item["BomFieldNameDir"] + "";
|
||||||
|
sourceRow["BomMxMainProduct"] = item["BomMxMainProduct"] + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8085,34 +8101,4 @@ namespace Lskj.PubBill
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cond">The cond.</param>
|
/// <param name="cond">The cond.</param>
|
||||||
/// <param name="dataRow">The data row.</param>
|
/// <param name="dataRow">The data row.</param>
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if X
|
||||||
private bool ValidateCond(string cond, DataRow dataRow)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
string condition = cond;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(cond)) return true;//如果值是空格或者空行,默认正确
|
|
||||||
cond = ReplaceHelper.ReplaceRowParam(dataRow, cond);
|
|
||||||
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
|
||||||
{
|
|
||||||
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
|
||||||
}
|
|
||||||
else if (dataRow == null)
|
|
||||||
{
|
|
||||||
result = ReplaceHelper.EvalCond(cond);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user