**
**
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Core.Metadata;
using System.ComponentModel;
using System.Data;
using Kingdee.BOS.App.Data;
using Kingdee.K3.Core.MFG.EntityHelper;
namespace ZY.ZZ.XX.BusinessPlugIn
{
//[Kingdee.BOS.Util.HotUpdate]
[Description("销售订单根据客户带出历史纪录")]
public class T_SALE_BringOutFields : AbstractBillPlugIn
{
public override void DataChanged(DataChangedEventArgs e)
{
switch (e.Field.Key.ToUpperInvariant())
{
case "FMATERIALID":
var index = e.Row;
var Materialobject = this.View.Model.GetValue("FMaterialId", index) as DynamicObject;
if (Materialobject == null)
{
this.View.ShowErrMessage("没有获取到物料信息!");
}
// 获取物料ID
var MaterialId = Materialobject.GetDynamicObjectItemValue<long>("Id");
//获取客户ID
var FCUSTobject = this.View.Model.GetValue("FCUSTID") as DynamicObject;
if (FCUSTobject == null)
{
this.View.ShowErrMessage("没有获取到客户信息!");
}
var FCUSTID = FCUSTobject.GetDynamicObjectItemValue<long>("Id");
var sql = string.Format(@"/*dialect*/SELECT TOP 1 F_WKYC_Text2, F_WKYC_Text3, F_WKYC_Text4, F_WKYC_Combo1, F_WKYC_Combo, F_WKYC_Combo3, F_WKYC_Combo2, F_WKYC_Text5
FROM T_SAL_ORDERENTRY as Tsaloe
inner join T_SAL_ORDER as Tsalo on Tsaloe.FID = Tsalo.FID
WHERE FMATERIALID = {0} and Tsalo.FCUSTID= {1} and FDOCUMENTSTATUS ='C'
ORDER BY FENTRYID DESC", MaterialId, FCUSTID);
//根据条件获取到需要的销售订单明细数据信息
var SALORDERObjects = DBUtils.ExecuteDynamicObject(this.Context, sql);
var SALORDERObject = SALORDERObjects.FirstOrDefault();
if (SALORDERObject != null)
{
//客户料号
//var F_WKYC_Text1 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Text1");
//客户牌号
var F_WKYC_Text2 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Text2");
//实际牌号
var F_WKYC_Text3 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Text3");
//公差
var F_WKYC_Text4 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Text4");
//是否充磁
var F_WKYC_Combo1 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Combo1");
//充磁方法
var F_WKYC_Combo = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Combo");
//镀层
var F_WKYC_Combo3 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Combo3");
//级别
var F_WKYC_Combo2 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Combo2");
//客户生产编号
var F_WKYC_Text5 = SALORDERObject.GetDynamicObjectItemValue<string>("F_WKYC_Text5");
// 将查询的值赋给客户料号字段
// this.View.Model.SetValue("F_WKYC_Text1", F_WKYC_Text1, index);
// 将查询的值赋给客户牌号字段
this.View.Model.SetValue("F_WKYC_Text2", F_WKYC_Text2, index);
// 将查询的值赋给实际牌号字段
this.View.Model.SetValue("F_WKYC_Text3", F_WKYC_Text3, index);
// 将查询的值赋给公差字段
this.View.Model.SetValue("F_WKYC_Text4", F_WKYC_Text4, index);
// 将查询的值赋给是否充磁字段
this.View.Model.SetValue("F_WKYC_Combo1", F_WKYC_Combo1, index);
// 将查询的值赋给充磁方法字段
this.View.Model.SetValue("F_WKYC_Combo", F_WKYC_Combo, index);
// 将查询的值赋给镀层字段
this.View.Model.SetValue("F_WKYC_Combo3", F_WKYC_Combo3, index);
// 将查询的值赋给级别字段
this.View.Model.SetValue("F_WKYC_Combo2", F_WKYC_Combo2, index);
// 将查询的值赋给客户生产编号字段
this.View.Model.SetValue("F_WKYC_Text5", F_WKYC_Text5, index);
}
this.View.UpdateView("FSaleOrderEntry");
break;
default:
break;
}
}
}
}