为移动单据写值更新事件,代码如下,为什么手机按了没反应,断点也跳不进去
using Kingdee.BOS.Mobile.PlugIn;
using Kingdee.BOS.Mobile.PlugIn.ControlModel;
using System;
using Kingdee.BOS.App.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Mobile.Const;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Orm.DataEntity;
using System.Data;
namespace SHJ.K3.AMB.AMB.Bussiness.PlugIn
{
public class ProductPurchaseMobile : AbstractMobileBillPlugin
{
#region 值更新
///
///
///
///
public override void DataChanged(DataChangedEventArgs e)
{
#region 变量定义
string strMaterialID=string.Empty,strSQL = string.Empty,strMaterialName=string.Empty,strModel=string.Empty;
decimal dPrice = 0, dQty = 0;
object objValue = string.Empty;
DynamicObjectCollection docResult = null;
#endregion
try
{
base.DataChanged(e);
this.Model.BeginIniti();
#region 根据产品编码带出名称和规格型号
if (e.Field.FieldName.Equals("FMATERIALID"))
{
objValue=this.Model.GetValue("FMATERIALID");
strMaterialID = (objValue == null ? string.Empty : objValue.ToString()); //产品编码
strSQL = "/*dialect*/" +
"SELECT \r\n" +
" a.FNUMBER, \r\n" +
" b.FNAME, \r\n" +
" b.FSPECIFICATION \r\n" +
"FROM T_BD_MATERIAL a \r\n" +
"INNER JOIN T_BD_MATERIAL_L b ON a.FMATERIALID=b.FMATERIALID AND b.FLOCALEID=2052 \r\n" +
"WHERE a.FMATERIALID="+strMaterialID+" \r\n";
docResult = DBUtils.ExecuteDynamicObject(this.Context, strSQL);
if (docResult != null && docResult.Count > 0)
{
objValue = docResult[0]["FNAME"];
strMaterialName = (objValue == null || objValue==DBNull.Value ? string.Empty : objValue.ToString()); //产品名称
objValue = docResult[0]["FSPECIFICATION"];
strModel = (objValue == null || objValue == DBNull.Value ? string.Empty : objValue.ToString()); //规格型号
this.Model.SetValue("FPRODUCTNAME", strMaterialName);
this.Model.SetValue("FMODEL", strModel);
}
}
#endregion
#region 根据单价和数量计算出金额
if (e.Field.FieldName.ToUpper().Equals("FPRICE".ToUpper()) || e.Field.FieldName.ToUpper().Equals("FQTY".ToUpper()))
{
objValue = this.Model.GetValue("FPRICE");
dPrice = (objValue == null ? 0 :Convert.ToDecimal(objValue)); //单价
objValue = this.Model.GetValue("FQTY");
dQty = (objValue == null ? 0 : Convert.ToDecimal(objValue)); //数量
this.Model.SetValue("FAMOUNT", dPrice * dQty);
}
#endregion
this.Model.EndIniti();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}
推荐阅读