0
This commit is contained in:
115
Pilot.Report.Exploitation/AccountsReceivable2/YourDataPlugIn2.cs
Normal file
115
Pilot.Report.Exploitation/AccountsReceivable2/YourDataPlugIn2.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||||
using Kingdee.BOS.Core.DynamicForm;
|
||||
using Kingdee.BOS.Core.Report.PlugIn;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Kingdee.BOS.App.Data;
|
||||
|
||||
namespace Pilot.Report.Exploitation.AccountsReceivable
|
||||
{
|
||||
/// <summary>
|
||||
/// 【表单插件】明细版-确认按钮
|
||||
/// </summary>
|
||||
[Description("【表单插件】明细版-确认按钮-添加数据库"), HotUpdate]
|
||||
public class YourDataPlugIn2: AbstractSysReportPlugIn
|
||||
{
|
||||
public override void BarItemClick(BarItemClickEventArgs e)
|
||||
{
|
||||
base.BarItemClick(e);
|
||||
// 判断 应收对账单【明细版】确认生成单据按钮
|
||||
if (e.BarItemKey == "Test_Button_2")
|
||||
{
|
||||
|
||||
#region 应收账款对账单数据添加
|
||||
|
||||
var reportModel = this.SysReportModel;
|
||||
|
||||
//单据头
|
||||
var rptTitles = reportModel.ReportTitles;
|
||||
string fClient = rptTitles.FirstOrDefault(a => a.TitleKey == "FClient").TitleValue.ToString();
|
||||
string fDate = rptTitles.FirstOrDefault(a => a.TitleKey == "FDate").TitleValue.ToString();
|
||||
int creatorId = Convert.ToInt32(this.Context.UserId);
|
||||
DateTime fDate2 = DateTime.Now;
|
||||
//单据体
|
||||
var list = reportModel.DataSource.Rows;
|
||||
|
||||
string sqlKH = string.Format(@"/*dialect*/Select FCUSTID From T_BD_CUSTOMER_L Where FNAME = '{0}'", fClient);
|
||||
|
||||
var sqlKHList = DBUtils.ExecuteDynamicObject(Context, sqlKH);
|
||||
|
||||
int fClientId = Convert.ToInt32(sqlKHList[0]["FCUSTID"]);
|
||||
|
||||
string sqlTest = string.Format(@"/*dialect*/Select * From MBBA_t_Cust100006 Where FClient = '{0}' AND Month(FDATE) = Month('{1}')", fClientId, fDate);
|
||||
|
||||
var sqlTestList = DBUtils.ExecuteDynamicObject(Context, sqlTest);
|
||||
|
||||
if (sqlTestList.Count() == 0)
|
||||
{
|
||||
decimal YFHpriceSum = 0;
|
||||
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (list[i]["Number"].ToString() == "合计")
|
||||
{
|
||||
YFHpriceSum = Math.Round(Convert.ToDecimal(list[i]["ShippedDebt"]), 2);
|
||||
}
|
||||
}
|
||||
|
||||
string sqlSelect = string.Format(@"/*dialect*/Select top 1 FId,FBillNo From MBBA_t_Cust100006 Order By FID DESC");
|
||||
|
||||
var sqlSelectList = DBUtils.ExecuteDynamicObject(Context, sqlSelect);
|
||||
|
||||
int FId = 1;
|
||||
string FBillNo = "YSDZ0001";
|
||||
string FBillNoSplit = "";
|
||||
|
||||
if (sqlSelectList.Count > 0)
|
||||
{
|
||||
FId = sqlSelectList[0]["FId"].Long2Int();
|
||||
FId = FId + 1;
|
||||
FBillNoSplit = sqlSelectList[0]["FBillNo"].ToString();
|
||||
int n = Convert.ToInt32(FBillNoSplit.Split('Z')[1]);
|
||||
if (n < 1000)
|
||||
{
|
||||
FBillNo = "YSDZ" + "0" + (n + 1);
|
||||
}
|
||||
else if (n < 100)
|
||||
{
|
||||
FBillNo = "YSDZ" + "00" + (n + 1);
|
||||
}
|
||||
else if (n < 10)
|
||||
{
|
||||
FBillNo = "YSDZ" + "000" + (n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
string sql = string.Format(@"Insert into MBBA_t_Cust100006 Values('{5}','{6}','A','{3}','{4}','',null,'{0}','{1}','{2}')",
|
||||
fClientId, fDate, YFHpriceSum, creatorId, fDate2, FId, FBillNo);
|
||||
|
||||
int num = DBUtils.Execute(Context, sql);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
this.View.ShowMessage("应收账款对账单生成完毕,已存储数据库!");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.View.ShowErrMessage("数据添加失败!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.View.ShowErrMessage("数据添加失败,已存在相同客户相同期间的对账单!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user