114 lines
4.8 KiB
C#
114 lines
4.8 KiB
C#
using Gatedge.K3.Pilot.PlugIn.Services.DBService;
|
|
using Kingdee.BOS.Core.Bill.PlugIn;
|
|
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
|
using Kingdee.BOS.Orm.DataEntity;
|
|
using Kingdee.BOS.Util;
|
|
using Kingdee.K3.BD.NewCode.Core.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.Sal_Order
|
|
{
|
|
[HotUpdate, Description("销售订单_表单插件")]
|
|
public class Bill : AbstractBillPlugIn
|
|
{
|
|
public override void DataChanged(DataChangedEventArgs e)
|
|
{
|
|
base.DataChanged(e);
|
|
//物料
|
|
if (e.Field.Key.EqualsIgnoreCase("FMaterialId"))
|
|
{
|
|
var materialId_Id = e.NewValue.Long2Int();
|
|
if (materialId_Id == 0)
|
|
return;
|
|
|
|
var custId_Id = this.View.Model.DataObject["CustId_Id"].Long2Int();
|
|
if (custId_Id == 0)
|
|
return;
|
|
|
|
var dal = new BDCustPriceDAL(this.Context);
|
|
var dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
var resData = dal.GetMaterialPrice(materialId_Id, custId_Id, dateTime);
|
|
if (resData != null && resData.Count > 0)
|
|
{
|
|
var data = resData[0];
|
|
|
|
// 协议价
|
|
var F_AGREEPRICE = data["F_AGREEPRICE"].Convert<decimal>();
|
|
this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, e.Row);
|
|
|
|
var custId = this.View.Model.GetValue("FCustID") as DynamicObject;
|
|
var creditClassificationId = custId["F_CreditClassification_Id"];
|
|
if (!creditClassificationId.IsNullOrEmptyOrWhiteSpace())
|
|
{
|
|
var creditClassification = custId["F_CreditClassification"] as DynamicObject;
|
|
var number = creditClassification["Number"].ToString();
|
|
|
|
if (number.EqualsIgnoreCase("KHXYFL013"))
|
|
{
|
|
// 大客户结算价
|
|
var F_BIGCUSTSETTLEPRICE = data["F_BIGCUSTSETTLEPRICE"].Convert<decimal>();
|
|
this.Model.SetValue("F_BIGCUSTSETTLEPRICE", F_BIGCUSTSETTLEPRICE, e.Row);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//客户
|
|
if (e.Field.Key.EqualsIgnoreCase("FCustID"))
|
|
{
|
|
var custId_Id = e.NewValue.Long2Int();
|
|
if (custId_Id == 0)
|
|
return;
|
|
|
|
var dal = new BDCustPriceDAL(this.Context);
|
|
var dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry");
|
|
if (details != null)
|
|
{
|
|
var entrys = this.View.Model.GetEntityDataObject(details);
|
|
foreach (var entry in entrys)
|
|
{
|
|
var rowIndex = this.View.Model.GetRowIndex(details, entry);
|
|
|
|
var materialId_Id = entry["MaterialId_Id"].Long2Int();
|
|
if (materialId_Id == 0)
|
|
continue;
|
|
|
|
var resData = dal.GetMaterialPrice(materialId_Id, custId_Id, dateTime);
|
|
|
|
if (resData != null && resData.Count > 0)
|
|
{
|
|
var data = resData[0];
|
|
|
|
// 协议价
|
|
var F_AGREEPRICE = data["F_AGREEPRICE"].Convert<decimal>();
|
|
this.Model.SetValue("F_AGREEPRICE", F_AGREEPRICE, rowIndex);
|
|
|
|
var custId = this.View.Model.GetValue("FCustID") as DynamicObject;
|
|
var creditClassificationId = custId["F_CreditClassification_Id"]?.ToString();
|
|
if (!creditClassificationId.IsNullOrEmptyOrWhiteSpace())
|
|
{
|
|
var creditClassification = custId["F_CreditClassification"] as DynamicObject;
|
|
var number = creditClassification["Number"].ToString();
|
|
|
|
if (number.EqualsIgnoreCase("KHXYFL013"))
|
|
{
|
|
// 大客户结算价
|
|
var F_BIGCUSTSETTLEPRICE = data["F_BIGCUSTSETTLEPRICE"].Convert<decimal>();
|
|
this.Model.SetValue("F_BIGCUSTSETTLEPRICE", F_BIGCUSTSETTLEPRICE, rowIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
} |