201 lines
7.7 KiB
C#
201 lines
7.7 KiB
C#
using DevExpress.Xpo.DB;
|
||
using Kingdee.BOS.Core.DynamicForm;
|
||
using Kingdee.BOS.Core.DynamicForm.PlugIn;
|
||
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
|
||
using Kingdee.BOS.Orm.DataEntity;
|
||
using Kingdee.BOS.Util;
|
||
using Newtonsoft.Json;
|
||
using Pilot_KD_Parino.Common;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using static Pilot_KD_Parino.QPHY_AutoWrire.Bill2;
|
||
|
||
namespace Pilot_KD_Parino.QPHY_AutoWrire
|
||
{
|
||
[HotUpdate]
|
||
[Description("收款核销3")]
|
||
//交互事件,在用
|
||
public class Bill3 : AbstractDynamicFormPlugIn
|
||
{
|
||
public List<CombinaClass> SaleBILLLIS = new List<CombinaClass>();
|
||
public List<CombinaClass> ReceiveBILLLIST = new List<CombinaClass>();
|
||
//拿来匹配的集合
|
||
public List<CombinaClass> SaleBILLLIS2 = new List<CombinaClass>();
|
||
/// <summary>
|
||
/// 开始
|
||
/// </summary>
|
||
/// <param name="e"></param>
|
||
public override void OnLoad(EventArgs e)
|
||
{
|
||
base.OnLoad(e);
|
||
|
||
//获取需要过滤的销售订单/应收单号
|
||
string stringFBILLNO = this.View.OpenParameter.GetCustomParameters()["stringFBILLNO"].ToString();
|
||
|
||
// 反序列化JSON字符串为List<StringFBILLNO>
|
||
List<StringFBILLNO> stringFBILLNOList = JsonConvert.DeserializeObject<List<StringFBILLNO>>(stringFBILLNO);
|
||
|
||
this.View.OpenParameter.Status = Kingdee.BOS.Core.Metadata.OperationStatus.EDIT;
|
||
|
||
SaleBILLLIS = new List<CombinaClass>();
|
||
ReceiveBILLLIST = new List<CombinaClass>();
|
||
List<CombinaClass> SaleBILLLISnew = new List<CombinaClass>();
|
||
List<CombinaClass> ReceiveBILLLISTNew = new List<CombinaClass>();
|
||
//删除一个单据体
|
||
this.View.Model.DeleteEntryData("FEntity");
|
||
|
||
var FOrgId = this.Context.CurrentOrganizationInfo.ID;
|
||
//DynamicObject FCustId = this.View.Model.GetValue("FCustId") as DynamicObject;
|
||
DynamicObjectCollection FCustId2 = this.View.Model.GetValue("FCustId") as DynamicObjectCollection;
|
||
|
||
//调用SQL获取数据
|
||
var WriteOrderDate = SQL.SqlManage.GetWriteOrderDate3(this.Context, Convert.ToString(FOrgId));
|
||
var WriteReceiveDate = SQL.SqlManage.GetWriteReceiveDate3(this.Context, Convert.ToString(FOrgId));
|
||
foreach (var item in WriteOrderDate)
|
||
{
|
||
SaleBILLLIS.Add(new CombinaClass()
|
||
{
|
||
FBIllNO = Convert.ToString(item["FBIllNO"]),
|
||
FCONTRACTNUMBER = Convert.ToString(item["F_CONTRACTNUMBER"]),
|
||
FClient = Convert.ToInt32(item["FCUSTID"]),
|
||
FDate = Convert.ToString(item["FDate"]),
|
||
FALLAMOUNT = Convert.ToDouble(item["FALLAMOUNT"]),
|
||
FYAMOUNT = Convert.ToDouble(item["FYAMOUNT"]),
|
||
FDAMOUNT = Convert.ToDouble(item["FDAMOUNT"]),
|
||
FCreated = Convert.ToInt32(item["FCREATORID"]),
|
||
FSalesman = Convert.ToInt32(item["FSALERID"]),
|
||
FIs30 = Convert.ToBoolean(item["FIs30"]),
|
||
FType = Convert.ToString(item["FType"]),
|
||
});
|
||
}
|
||
SaleBILLLIS2 = SaleBILLLIS.Where(t => t.FIs30 == true).ToList();
|
||
|
||
//获取需要删除的单据体
|
||
var SaleBILLLIS3 = new List<CombinaClass>();
|
||
|
||
foreach (var item in stringFBILLNOList)
|
||
{
|
||
foreach (var item2 in SaleBILLLIS2)
|
||
{
|
||
if (item2.FBIllNO.Equals(item.FBILLNO))
|
||
{
|
||
SaleBILLLIS3.Add(item2);
|
||
}
|
||
}
|
||
}
|
||
|
||
foreach (var item in SaleBILLLIS3)
|
||
{
|
||
SaleBILLLIS2.Remove(item);
|
||
}
|
||
|
||
//绑定销售订单数据 SaleBILLLIS2
|
||
for (int i = 0; i < SaleBILLLIS2.Count; i++)
|
||
{
|
||
int rowindex = this.View.Model.GetEntryRowCount("FEntity");
|
||
this.View.Model.CreateNewEntryRow("FEntity");
|
||
//单据编号
|
||
this.View.Model.SetValue("FBILLNO", SaleBILLLIS2[i].FBIllNO, i);
|
||
//日期
|
||
this.View.Model.SetValue("FDate", DateTime.Now.AddDays(-1 * Convert.ToInt32(SaleBILLLIS2[i].FDate)).ToString("yyyy-MM-dd"), i);
|
||
//金额
|
||
this.View.Model.SetValue("F_MBBA_Decimal_c1c", SaleBILLLIS2[i].FALLAMOUNT, i);
|
||
//类型
|
||
this.View.Model.SetValue("FType", SaleBILLLIS2[i].FType, i);
|
||
//纸质合同号
|
||
this.View.Model.SetValue("FCONTRACTNUMBER", SaleBILLLIS2[i].FCONTRACTNUMBER, i);
|
||
//客户名称
|
||
this.View.Model.SetValue("FClient", SaleBILLLIS2[i].FClient, i);
|
||
//已核销金额
|
||
this.View.Model.SetValue("F_MBBA_Decimal_vb1", SaleBILLLIS2[i].FYAMOUNT, i);
|
||
//待核销金额
|
||
this.View.Model.SetValue("F_MBBA_Decimal_emq", SaleBILLLIS2[i].FDAMOUNT, i);
|
||
//商务人员
|
||
this.View.Model.SetValue("FCreated", SaleBILLLIS2[i].FCreated, i);
|
||
//销售员
|
||
this.View.Model.SetValue("FSalesman", SaleBILLLIS2[i].FSalesman, i);
|
||
|
||
this.View.UpdateView("FEntity");
|
||
}
|
||
|
||
}
|
||
|
||
public class StringFBILLNOANDList
|
||
{
|
||
public string FBILLNO { get; set; }
|
||
public List<StringFBILLNO> FBILLNOList { get; set; } = new List<StringFBILLNO>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭窗口并传值
|
||
/// </summary>
|
||
/// <param name="e"></param>
|
||
public override void BeforeClosed(BeforeClosedEventArgs e)
|
||
{
|
||
base.BeforeClosed(e);
|
||
|
||
//获取当前点击的单据号
|
||
string fBillNo = this.View.OpenParameter.GetCustomParameters()["fBillNo"].ToString();
|
||
|
||
//获取复选框选择的值
|
||
var SaleBILLLIS2 = new List<StringFBILLNO>();
|
||
|
||
//获取收款单单据体数据
|
||
DynamicObjectCollection FEntity = this.View.Model.DataObject["FEntity"] as DynamicObjectCollection;
|
||
//新建存储类
|
||
List<StringFBILLNO> stringFBILLNO = new List<StringFBILLNO>();
|
||
foreach (var item in FEntity)
|
||
{
|
||
if (Convert.ToBoolean(item["F_MBBA_CheckBox_qtr"]))
|
||
{
|
||
SaleBILLLIS2.Add(new StringFBILLNO()
|
||
{
|
||
FBILLNO = Convert.ToString(item["FBIllNO"]),
|
||
});
|
||
}
|
||
}
|
||
|
||
StringFBILLNOANDList stringFBILLNOANDList = new StringFBILLNOANDList();
|
||
|
||
//将值存储起来
|
||
stringFBILLNOANDList.FBILLNO = fBillNo;
|
||
stringFBILLNOANDList.FBILLNOList.AddRange(SaleBILLLIS2);
|
||
|
||
#region 方式1:用ReturnToParentWindow方法返回数据
|
||
|
||
var result = new FormResult(stringFBILLNOANDList);
|
||
|
||
this.View.ReturnToParentWindow(result);
|
||
|
||
#endregion
|
||
|
||
#region 方式2:直接往父对象Session集合写入数据
|
||
|
||
//this.View.ParentFormView.Session["returnData2"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点击按钮操作
|
||
/// </summary>
|
||
/// <param name="e"></param>
|
||
public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
|
||
{
|
||
base.AfterBarItemClick(e);
|
||
|
||
//确定选择
|
||
if (e.BarItemKey.ToString().Equals("MBBA_tbButton"))
|
||
{
|
||
// 关闭表单并传递选择的数据
|
||
this.View.Close();
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|