代码拉取完成,页面将自动刷新
using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Resource;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
namespace JW.Plugins
{
[Description("切张需求列表下推-派工")]
public class QiezhangXQDToPGD_Convert : AbstractConvertPlugIn
{
public override void OnInSelectedRow(InSelectedRowEventArgs e)
{
if (!string.IsNullOrEmpty(e.SelectedRows.FirstOrDefault<ListSelectedRow>().EntryPrimaryKeyValue))
{
//下推插件,1、多选需求时需校验物料一致性
if (!e.PkKey.EqualsIgnoreCase(e.SourceBusinessInfo.GetForm().PkFieldName))
{
IEnumerable<string> values =
from p in e.SelectedRows
where !string.IsNullOrEmpty(p.EntryPrimaryKeyValue)
select p.EntryPrimaryKeyValue;
string ids = string.Join(",", values);
string text = this.chkMtrlisSame(e.Context, ids);
if (!text.Equals("1"))
{
throw new KDExceptionValidate("convert", ResManager.LoadKDString("不符合下推条件", "004002030004060", SubSystemType.SCM, new object[0]), ResManager.LoadKDString("请选择相同产品的记录进行下推!", "004002030004063", SubSystemType.SCM, new object[0]));
}
}
}
base.OnInSelectedRow(e);
}
private string GetNeedQuotaData(GetSourceDataEventArgs e)
{
string FEntryIDSTR = "";
foreach (DynamicObject current in e.SourceData)
{
string FEntryID = current["FEntity_FEntryID"].ToString();
FEntryIDSTR = FEntryID + "," + FEntryIDSTR;
}
if (FEntryIDSTR.EndsWith(","))
FEntryIDSTR = FEntryIDSTR.SubStr(0, FEntryIDSTR.Length - 1);
return FEntryIDSTR;
}
//下推插件,多选需求时需校验物料一致性
public override void OnGetSourceData(GetSourceDataEventArgs e)
{
if (e.SourceData != null && e.SourceData.Count > 0)
{
string FEntryIDSTR = "";
FEntryIDSTR = this.GetNeedQuotaData(e);
string text = this.chkMtrlisSame(e.Context, FEntryIDSTR);
if (!text.Equals("1"))
{
throw new KDExceptionValidate("convert", ResManager.LoadKDString("不符合下推条件", "004002030004060", SubSystemType.SCM, new object[0]), ResManager.LoadKDString("请选择相同产品的记录进行下推!", "004002030004063", SubSystemType.SCM, new object[0]));
}
}
base.OnGetSourceData(e);
}
private string GetCobyEntryIds(Context ctx, string ids)
{
string strSQL = string.Format("SELECT t1.FENTRYID FROM T_PUR_POORDERENTRY t1\r\njoin T_PUR_POORDERENTRY t2 on t1.FID=t2.FID and t1.FGROUP=t2.FGROUP \r\nleft join T_PUR_POORDER T3 ON T3.Fid=T1.Fid \r\nWHERE t2.FENTRYID in ({0}) AND t1.FPRODUCTTYPE<>'1' AND T3.Fbusinesstype='WW' ", ids);
List<long> values = (
from p in DBUtils.ExecuteEnumerable(ctx, strSQL, CommandType.Text, new SqlParam[0])
select Convert.ToInt64(p.GetValue(0))).ToList<long>();
return string.Join<long>(",", values);
}
/// <summary>
/// 1、多选需求时需校验物料一致性
/// </summary>
/// <param name="ctx"></param>
/// <param name="ids"></param>
/// <returns></returns>
private string chkMtrlisSame(Context ctx, string ids)
{
string strSQL = string.Format("SELECT count( distinct F_UUU_BASE_WL) cnt FROM uuu_t_Cust100035 T1 JOIN uuu_t_Cust_Entry100113 T2 ON T1.FID =T2.FID where T2.FENTRYID in ({0})", ids);
List<long> values = (
from p in DBUtils.ExecuteEnumerable(ctx, strSQL, CommandType.Text, new SqlParam[0])
select Convert.ToInt64(p.GetValue(0))).ToList<long>();
return string.Join<long>(",", values);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。