1 Star 0 Fork 0

momoxxx/cq.Plugins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SAL_SIMULATEQUOTEEdit.cs 7.42 KB
一键复制 编辑 原始数据 按行查看 历史
momoxxx 提交于 2024-01-09 14:40 . 添加项目文件。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using Kingdee.BOS;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.ControlElement;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Business.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.Bill.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Core.Interaction;
using Kingdee.BOS.App;
using Kingdee.BOS.App.Core;
/// <summary>
/// 多斯达
/// 宇祥 2019.04.12
/// </summary>
namespace DomuStar.Plugins
{
[Description("模拟报价单")]
public class SAL_SIMULATEQUOTEEdit : AbstractBillPlugIn
{
public override void BarItemClick(BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.EqualsIgnoreCase("tbCalPrice"))//计算单价
{
//////分录
//string sFid = "";
//sFid = this.View.Model.DataObject["Id"].ToString();
//double dPriceSum = 0;//单价汇总,用来放到表头父物单价
////按公式取价格
//string ls_sql = "/*dialect*/ SET NOCOUNT ON EXEC SP_KDZS_CALPRICE " + sFid + ",0,0,0";
//System.Data.IDataReader data3 = Kingdee.BOS.App.Data.DBUtils.ExecuteReader(this.Context, ls_sql);
//int i = 0;
//while (data3.Read())
//{
// View.Model.SetValue("FCMatPrice", Convert.ToDouble(data3["FPRICE"].ToString()), i);//材料单价
// ((IDynamicFormView)View).InvokeFieldUpdateService("FCMatPrice", i);
// i++;
//}
////分录
for (int i = 0; i < this.View.Model.GetEntryRowCount("FDetailEntity"); i++)
{
getPrice(i);
}
//设置表头父项编码
if (this.View.Model.GetEntryRowCount("FEntity") > 0)
{
if (View.Model.GetValue("FBomId", 0) != null)
{
string FBomId = (this.View.Model.GetValue("FBomId", 0) as DynamicObject)["id"].ToString();//
if (!FBomId.Equals(""))
{
string ls_sql = "/*dialect*/ SELECT T2.FNUMBER FROM T_ENG_BOM T1 JOIN T_BD_MATERIAL T2 ON T1.FMATERIALID=T2.FMATERIALID WHERE T1.FID= " + FBomId;
using (System.Data.IDataReader data3 = Kingdee.BOS.App.Data.DBUtils.ExecuteReader(this.Context, ls_sql))
{
while (data3.Read())
{
View.Model.SetValue("F_PAEZ_Text", data3["FNUMBER"].ToString(), 0);//
}
}
}
}
}
}
}
private void getPrice(int row)
{
//double dResult = 0, dQtyS = 0, dQtyE = 0, FTaxRate = 0, F_zskd_LVPrice = 0, FSupplierID = 0;
string sItemId = "", sCustId = "", FMaterialErpClsID = "";
if (View.Model.GetValue("FCMatlId", row) != null)
{
sItemId = (this.View.Model.GetValue("FCMatlId", row) as DynamicObject)["id"].ToString();//产品编码
FMaterialErpClsID = ((this.View.Model.GetValue("FCMatlId", row) as DynamicObject)["MaterialBase"] as DynamicObjectCollection)[0]["ErpClsID"].ToString();//
}
if (View.Model.GetValue("FCustomerID", 0) != null)
sCustId = (this.View.Model.GetValue("FCustomerID", 0) as DynamicObject)["id"].ToString();//客户编码
if (!sItemId.Equals("") && !sCustId.Equals(""))
{
int iCount = 0;
//按公式取价格
string ls_sql = "/*dialect*/ SET NOCOUNT ON EXEC SP_KDZS_SAL_SIMULATEQUOTE_GetPrice " + sItemId + "," + sCustId;
using (System.Data.IDataReader data3 = Kingdee.BOS.App.Data.DBUtils.ExecuteReader(this.Context, ls_sql))
{
//this.View.ShowErrMessage(ls_sql);
while (data3.Read())
{
iCount++;
if (FMaterialErpClsID.Equals("3"))//委外
{
View.Model.SetItemValueByNumber("FCSubPriceFrom", "CLDJLY13_SYS", row);
View.Model.SetValue("FCSubPrice", Convert.ToDouble(data3["FPRICE"].ToString()), row);//委外加工单价
View.Model.SetValue("F_kdzs_CSubPriceTAX", Convert.ToDouble(data3["TAXmtrlPrice"].ToString()), row);//含税委外加工单价
}
else
{
View.Model.SetItemValueByNumber("FCMatPriceFrom", "CLDJLY02_SYS", row); //材料单价来源
View.Model.SetValue("FCMatPrice", Convert.ToDouble(data3["FPRICE"].ToString()), row);//材料单价
View.Model.SetValue("F_zs_TAXmtrlPrice", Convert.ToDouble(data3["TAXmtrlPrice"].ToString()), row);//含税材料单价
View.Model.SetItemValueByID("F_PAEZ_SUPPLIERID", data3["FSUPPLIERID"].ToString(), row);//供应商
}
}
if (iCount == 0)//如果取不到值就清空
{
if (FMaterialErpClsID.Equals("3"))//委外
{
View.Model.SetItemValueByNumber("FCSubPriceFrom", "", row);
View.Model.SetValue("FCSubPrice", 0, row);//委外加工单价
View.Model.SetValue("F_kdzs_CSubPriceTAX", 0, row);//含税委外加工单价
((IDynamicFormView)View).InvokeFieldUpdateService("FCSubPrice", row);
((IDynamicFormView)View).InvokeFieldUpdateService("FCSubPriceFrom", row);
}
//else
//{
// View.Model.SetItemValueByNumber("FCMatPriceFrom", "", row); //材料单价来源
// View.Model.SetValue("FCMatPrice", 0, row);//材料单价
// View.Model.SetValue("F_zs_TAXmtrlPrice", 0, row);//含税材料单价
// View.Model.SetItemValueByID("F_PAEZ_SUPPLIERID", 0, row);//供应商
// ((IDynamicFormView)View).InvokeFieldUpdateService("FCMatPrice", row);
//}
}
}
}
((IDynamicFormView)View).InvokeFieldUpdateService("FCSubPrice", row);
((IDynamicFormView)View).InvokeFieldUpdateService("FCMatPrice", row);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/momoxxx/cq.-plugins.git
git@gitee.com:momoxxx/cq.-plugins.git
momoxxx
cq.-plugins
cq.Plugins
master

搜索帮助