添加保存刷新
This commit is contained in:
parent
c7156ef7ce
commit
a58b10e851
28
Pilot_KD_Parino/AR_SalesVATInvoice/Bill.cs
Normal file
28
Pilot_KD_Parino/AR_SalesVATInvoice/Bill.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Kingdee.BOS.Core.Bill.PlugIn;
|
||||||
|
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||||
|
using Kingdee.BOS.Util;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Pilot_KD_Parino.AR_SalesVATInvoice
|
||||||
|
{
|
||||||
|
[HotUpdate, Description("销售增值税专用发票_表单插件")]
|
||||||
|
public class Bill : AbstractBillPlugIn
|
||||||
|
{
|
||||||
|
public override void AfterDoOperation(AfterDoOperationEventArgs e)
|
||||||
|
{
|
||||||
|
base.AfterDoOperation(e);
|
||||||
|
|
||||||
|
string opt = e.Operation.Operation;
|
||||||
|
|
||||||
|
// 保存成功后刷新界面(参考收款核销5的刷新方式)
|
||||||
|
if (opt == "Save" && e.OperationResult.IsSuccess)
|
||||||
|
{
|
||||||
|
// 刷新单据体视图
|
||||||
|
this.View.UpdateView("SALESICENTRY");
|
||||||
|
// 刷新整个界面
|
||||||
|
this.View.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -2,15 +2,14 @@ using Kingdee.BOS;
|
|||||||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||||
using Kingdee.BOS.Log;
|
using Kingdee.BOS.Log;
|
||||||
|
using Kingdee.BOS.Orm;
|
||||||
using Kingdee.BOS.Orm.DataEntity;
|
using Kingdee.BOS.Orm.DataEntity;
|
||||||
using Kingdee.BOS.ServiceHelper;
|
using Kingdee.BOS.ServiceHelper;
|
||||||
using Kingdee.BOS.Util;
|
using Kingdee.BOS.Util;
|
||||||
using Pilot_KD_Parino.Common;
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Pilot_KD_Parino.AR_SalesVATInvoice.ServicePlugIn
|
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.AR_SalesVATInvoice.ServicePlugIn
|
||||||
{
|
{
|
||||||
[HotUpdate, Description("销售增值税专用发票_保存后事件")]
|
[HotUpdate, Description("销售增值税专用发票_保存后事件")]
|
||||||
public class AfterSave : AbstractOperationServicePlugIn
|
public class AfterSave : AbstractOperationServicePlugIn
|
||||||
@ -18,26 +17,24 @@ namespace Pilot_KD_Parino.AR_SalesVATInvoice.ServicePlugIn
|
|||||||
public override void OnPreparePropertys(PreparePropertysEventArgs e)
|
public override void OnPreparePropertys(PreparePropertysEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnPreparePropertys(e);
|
base.OnPreparePropertys(e);
|
||||||
// 添加需要加载的字段
|
// 根据日志中的实际实体属性名来添加
|
||||||
e.FieldKeys.Add("FENTRYID");
|
|
||||||
e.FieldKeys.Add("FIDD");
|
e.FieldKeys.Add("FIDD");
|
||||||
e.FieldKeys.Add("FSEQQ");
|
e.FieldKeys.Add("FSEQQ");
|
||||||
e.FieldKeys.Add("FSRCBILLTYPEID");
|
e.FieldKeys.Add("SRCBILLTYPEID"); // 实体属性名(没有F前缀)
|
||||||
e.FieldKeys.Add("FSRCBILLNO");
|
e.FieldKeys.Add("SRCBILLNO"); // 实体属性名(没有F前缀)
|
||||||
|
e.FieldKeys.Add("SEQ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
|
|
||||||
|
public override void EndOperationTransaction(EndOperationTransactionArgs e)
|
||||||
{
|
{
|
||||||
base.AfterExecuteOperationTransaction(e);
|
base.EndOperationTransaction(e);
|
||||||
|
|
||||||
|
|
||||||
foreach (var dataEntity in e.DataEntitys)
|
foreach (var dataEntity in e.DataEntitys)
|
||||||
{
|
{
|
||||||
var billObj = dataEntity as DynamicObject;
|
var billObj = dataEntity as DynamicObject;
|
||||||
if (billObj == null)
|
if (billObj == null)
|
||||||
continue;
|
continue;
|
||||||
var sdsas = JsonHelper.ToJson(billObj);
|
|
||||||
Logger.Error("销售增值税专用发票", sdsas, new Exception());
|
|
||||||
// 获取单据体
|
// 获取单据体
|
||||||
var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
|
var entrys = billObj["SALESICENTRY"] as DynamicObjectCollection;
|
||||||
if (entrys == null || entrys.Count == 0)
|
if (entrys == null || entrys.Count == 0)
|
||||||
@ -45,53 +42,59 @@ namespace Pilot_KD_Parino.AR_SalesVATInvoice.ServicePlugIn
|
|||||||
|
|
||||||
foreach (var entry in entrys)
|
foreach (var entry in entrys)
|
||||||
{
|
{
|
||||||
var entryId = Convert.ToInt64(entry["FENTRYID"]);
|
// 使用 Id 获取主键值
|
||||||
|
var entryId = Convert.ToInt64(entry.GetPrimaryKeyValue());
|
||||||
var fidd = entry["FIDD"];
|
var fidd = entry["FIDD"];
|
||||||
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
var fiddValue = fidd == null ? 0 : Convert.ToInt64(fidd);
|
||||||
|
|
||||||
if (fiddValue > 0)
|
if (fiddValue > 0)
|
||||||
{
|
{
|
||||||
// FIDD > 0 时,判断是否需要回写
|
// FIDD > 0 时,判断是否需要回写
|
||||||
var srcBillNo = entry["FSRCBILLNO"]?.ToString() ?? "";
|
var srcBillNo = entry["SRCBILLNO"]?.ToString() ?? "";
|
||||||
Logger.Error("销售增值税专用发票", "56", new Exception());
|
|
||||||
// FIDD != 当前行FENTRYID 且 源单编号为空 时才回写
|
// 判断条件:FIDD != 当前行ID 且 源单编号为空
|
||||||
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
if (fiddValue != entryId && string.IsNullOrWhiteSpace(srcBillNo))
|
||||||
{
|
{
|
||||||
// 查询源单据体信息(主键=FIDD的明细行)
|
// 查询源单据体信息(FID = fiddValue的明细行)
|
||||||
|
// 这里使用数据库字段名(带F前缀)
|
||||||
var sql = $@"/*dialect*/
|
var sql = $@"/*dialect*/
|
||||||
SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ
|
SELECT FSRCBILLTYPEID, FSRCBILLNO, FSEQ
|
||||||
FROM T_IV_SALESICENTRY
|
FROM T_IV_SALESICENTRY
|
||||||
WHERE FENTRYID = {fiddValue}";
|
WHERE FENTRYID = {fiddValue}";
|
||||||
Logger.Error("销售增值税专用发票", sql, new Exception());
|
Logger.Error("销售增值税专用发票", sql, new Exception());
|
||||||
|
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||||
var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
var result = DBServiceHelper.ExecuteDynamicObject(this.Context, sql);
|
||||||
if (result == null || result.Count == 0)
|
if (result == null || result.Count == 0)
|
||||||
continue;
|
continue;
|
||||||
Logger.Error("销售增值税专用发票", "69", new Exception());
|
|
||||||
var srcData = result[0];
|
var srcData = result[0];
|
||||||
var srcBillTypeId = srcData["FSRCBILLTYPEID"];
|
// 注意:SQL查询返回的是数据库字段名(带F前缀)
|
||||||
var srcBillNoValue = srcData["FSRCBILLNO"];
|
var srcBillTypeId = srcData["FSRCBILLTYPEID"]?.ToString() ?? "";
|
||||||
|
var srcBillNoValue = srcData["FSRCBILLNO"]?.ToString() ?? "";
|
||||||
|
|
||||||
// 回写当前单据体:源单类型、源单编号
|
// 回写当前单据体:源单类型、源单编号
|
||||||
|
// 这里使用数据库字段名(带F前缀)
|
||||||
var updateSql = $@"/*dialect*/
|
var updateSql = $@"/*dialect*/
|
||||||
UPDATE T_IV_SALESICENTRY
|
UPDATE T_IV_SALESICENTRY
|
||||||
SET FSRCBILLTYPEID = '{srcBillTypeId}',
|
SET FSRCBILLTYPEID = '{srcBillTypeId.Replace("'", "''")}',
|
||||||
FSRCBILLNO = '{srcBillNoValue}'
|
FSRCBILLNO = '{srcBillNoValue.Replace("'", "''")}'
|
||||||
WHERE FENTRYID = {entryId}";
|
WHERE FENTRYID = {entryId}";
|
||||||
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||||
Logger.Error("销售增值税专用发票", "80", new Exception());
|
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||||
DBServiceHelper.Execute(this.Context, updateSql);
|
DBServiceHelper.Execute(this.Context, updateSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Error("销售增值税专用发票", "", new Exception());
|
// FIDD <= 0 时,把当前行FID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
||||||
// FIDD <= 0 时,把当前行FENTRYID赋值给FIDD,同时把FSEQ赋值给FSEQQ
|
var seq = entry["SEQ"]?.ToString() ?? "0";
|
||||||
var updateSql = $@"/*dialect*/
|
var updateSql = $@"/*dialect*/
|
||||||
UPDATE T_IV_SALESICENTRY
|
UPDATE T_IV_SALESICENTRY
|
||||||
SET FIDD = FENTRYID,
|
SET FIDD = {entryId},
|
||||||
FSEQQ = FSEQ
|
FSEQQ = '{seq.Replace("'", "''")}'
|
||||||
WHERE FENTRYID = {entryId}";
|
WHERE FENTRYID = {entryId}";
|
||||||
Logger.Error("销售增值税专用发票", "93", new Exception());
|
Logger.Error("销售增值税专用发票", updateSql, new Exception());
|
||||||
|
Logger.Error("销售增值税专用发票", "78", new Exception());
|
||||||
DBServiceHelper.Execute(this.Context, updateSql);
|
DBServiceHelper.Execute(this.Context, updateSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,4 +102,3 @@ WHERE FENTRYID = {entryId}";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -322,6 +322,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AR_SalesVATInvoice\Bill.cs" />
|
||||||
<Compile Include="AR_SalesVATInvoice\ServicePlugIn\AfterSave.cs" />
|
<Compile Include="AR_SalesVATInvoice\ServicePlugIn\AfterSave.cs" />
|
||||||
<Compile Include="Common\BOSCommon.cs" />
|
<Compile Include="Common\BOSCommon.cs" />
|
||||||
<Compile Include="Common\CombinaAddClass1.cs" />
|
<Compile Include="Common\CombinaAddClass1.cs" />
|
||||||
|
|||||||
BIN
Pilot_KD_Parino/bin/Debug/GZ_KD_Parino.dll
Normal file
BIN
Pilot_KD_Parino/bin/Debug/GZ_KD_Parino.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user