This commit is contained in:
2025-04-18 10:10:08 +08:00
parent 8dcb23d7ee
commit 1ee535273b
5 changed files with 300 additions and 83 deletions

View File

@@ -2,6 +2,7 @@
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
using Kingdee.BOS.App.Core.Utils;
using Kingdee.BOS.BusinessEntity.BusinessFlow;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
@@ -51,6 +52,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var showParameter = new DynamicFormShowParameter();
showParameter.FormId = "NAAD_ZiDongHeXiao";
showParameter.ParentPageId = this.View.PageId;
showParameter.PageId = this.View.PageId + "_Filter";
showParameter.OpenStyle.CacheId = this.View.PageId;
this.View.ShowForm(showParameter, action => FilterCallBack(action));
return;
/*
SaleBILLLIS = new List<CombinaClass>();
ReceiveBILLLIST = new List<CombinaClass>();
List<CombinaClass> SaleBILLLISnew = new List<CombinaClass>();
@@ -58,16 +69,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//删除四个单据体
this.View.Model.DeleteEntryData("FEntity");
this.View.Model.DeleteEntryData("FEntity2");
var FOrgId = this.Context.CurrentOrganizationInfo.ID;
var FShuaXin = this.View.Model.GetValue("FShuaXin");
//调用SQL获取数据
var WriteOrderDate = SQL.SqlManage_yuyubo.GetWriteOrderDate3(this.Context, Convert.ToString(FOrgId));
var WriteReceiveDate = SQL.SqlManage_yuyubo.GetWriteReceiveDate3(this.Context, Convert.ToString(FOrgId));
var WriteReceiveDate = SQL.SqlManage_yuyubo.GetWriteReceiveDate3(this.Context, Convert.ToString(FOrgId));
SaleBILLLIS = WriteOrderDate.Select(item => new CombinaClass
{
Fid= Convert.ToInt32(item["FID"]),
Fid = Convert.ToInt32(item["FID"]),
FBIllNO = Convert.ToString(item["FBIllNO"]),
FCONTRACTNUMBER = Convert.ToString(item["F_CONTRACTNUMBER"]),
FClient = Convert.ToInt32(item["FCUSTID"]),
@@ -85,7 +96,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FInvoiceAmount = Convert.ToDecimal(item["FInvoiceAmount"]),
}).ToList();
ReceiveBILLLIST = WriteReceiveDate.Select(item => new CombinaClass
{
Fid = Convert.ToInt32(item["FID"]),
@@ -99,7 +110,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FRemark = Convert.ToString(item["FREMARK"]),
FSalesman = Convert.ToInt32(item["FSALEERID"]),
F_RowNew = 1,
BenCi=0,
BenCi = 0,
}).ToList();
var kehu = ReceiveBILLLIST.Select(t => t.FClient).Distinct().ToList();
@@ -109,7 +120,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//绑定销售订单数据
for (int i = 0; i < SaleBILLLIS2.Count; i++)
{
int rowindex = this.View.Model.GetEntryRowCount("FEntity");
this.View.Model.CreateNewEntryRow("FEntity");
//单据编号
@@ -165,6 +176,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
}
this.View.UpdateView("FEntity2");
*/
}
/// <summary>
@@ -267,7 +279,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FISHX = item["FISHX2"]?.ToString(),
FWeiYi = item["FWeiYi2"]?.ToString(),
}).ToList();
//获取纸质合同号
List<string> fString = new List<string>();
@@ -275,8 +287,8 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//修改销售订单/应收单
foreach (var item in stringFBILLNOANDList[0].FBILLNOList)
{
var item2 = SaleBILLLIS.FirstOrDefault(h=>h.FBIllNO==item.FBILLNO);
var item2 = SaleBILLLIS.FirstOrDefault(h => h.FBIllNO == item.FBILLNO);
if (item2 != null)
{
SaleBILLLIS2.Add(item2);
@@ -368,6 +380,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
{
base.AfterBarItemClick(e);
//点击过滤按钮,弹出过滤窗体
if (e.BarItemKey.Equals("MBBA_tbButton", StringComparison.OrdinalIgnoreCase))
{
var showParameter = new DynamicFormShowParameter();
showParameter.FormId = "NAAD_ZiDongHeXiao";
showParameter.ParentPageId = this.View.PageId;
showParameter.PageId = this.View.PageId + "_Filter";
showParameter.OpenStyle.CacheId = this.View.PageId;
this.View.ShowForm(showParameter, action => FilterCallBack(action));
}
//自动匹配
if (e.BarItemKey.ToString().Equals("MBBA_tbButton_2"))
{
@@ -375,7 +397,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//销售订单绑定数据
SaleBILLLIS = new List<CombinaClass>();
DynamicObjectCollection FEntity = this.View.Model.DataObject["FEntity"] as DynamicObjectCollection;
SaleBILLLIS = FEntity.Select(item => new CombinaClass
{
FBIllNO = Convert.ToString(item["FBILLNO"]),
@@ -396,7 +418,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
var ReceiveBILLLIST2 = new List<CombinaClass>();
//获取收款单单据体数据
DynamicObjectCollection FEntity2 = this.View.Model.DataObject["FEntity2"] as DynamicObjectCollection;
ReceiveBILLLIST2 = FEntity2.Select(item => new CombinaClass
{
FBIllNO = item["FBILLNO2"]?.ToString(),
@@ -414,11 +436,11 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
}).ToList();
//重置并只取父级树形数据
ReceiveBILLLIST = new List<CombinaClass>();
ReceiveBILLLIST = ReceiveBILLLIST2.Where(a => a.F_RowNew == 1 && a.FISHX != "已核销配对").OrderBy(t=>t.FClient).ThenBy(t=>t.FCONTRACTNUMBER).ThenBy(t=>t.FDate).ToList();
ReceiveBILLLIST = ReceiveBILLLIST2.Where(a => a.F_RowNew == 1 && a.FISHX != "已核销配对").OrderBy(t => t.FClient).ThenBy(t => t.FCONTRACTNUMBER).ThenBy(t => t.FDate).ToList();
List<string> FBILLNOLIST = new List<string>();
List<int> FClient = new List<int>();
List<DataItem> result = new List<DataItem>();
var FStartTime = DateTime.Now;
var FStartTime = DateTime.Now;
#region 2025-04-07
#region
@@ -446,7 +468,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
return;
var temp11 = temp111.FBIllNO;
deleteFBIllNOList.Add(temp11);
var item = SaleBILLLISNew.Where(h => h.FBIllNO == temp11).OrderBy(h=>h.FDate).FirstOrDefault();
var item = SaleBILLLISNew.Where(h => h.FBIllNO == temp11).OrderBy(h => h.FDate).FirstOrDefault();
//更新销售订单数据
item.FSKBIllNO = t;
item.FISHX = "已核销配对";
@@ -477,7 +499,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
List<string> deleteFBIllNOList = new List<string>();
saleList1.ForEach(t =>
{
var temp111 = oneToOneTemp.Where(h => h.FBIllNO == t && !deleteFBIllNOList.Contains(h.UFbillNo)).OrderBy(h=>h.UFbillNo).FirstOrDefault();
var temp111 = oneToOneTemp.Where(h => h.FBIllNO == t && !deleteFBIllNOList.Contains(h.UFbillNo)).OrderBy(h => h.UFbillNo).FirstOrDefault();
if (temp111 == null)
return;
var temp11 = temp111.UFbillNo;
@@ -511,17 +533,17 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//先挑1张收款单对应多张张销售订单
var SaleBILLLIS2Sa2 = SaleBILLLISNew.Where(t => t.FISHX != "已核销配对" && t.FDAMOUNT > 0).OrderBy(t => t.FClient).ThenByDescending(t => t.FBIllNO).ToList();
ReceiveBILLLIST = ReceiveBILLLIST2.Where(a => a.F_RowNew == 1 && a.FISHX != "已核销配对" && a.FDAMOUNT > 0 ).OrderBy(t => t.FClient).ThenByDescending(t => t.FBIllNO).ToList();
ReceiveBILLLIST = ReceiveBILLLIST2.Where(a => a.F_RowNew == 1 && a.FISHX != "已核销配对" && a.FDAMOUNT > 0).OrderBy(t => t.FClient).ThenByDescending(t => t.FBIllNO).ToList();
//打包式匹配法,按时间倒序逐一核销掉.
ReceiveBILLLIST.ForEach(t =>
{
var tempList = SaleBILLLIS2Sa2.Where(h => h.FClient == t.FClient && h.FISHX != "已核销配对" && t.FDAMOUNT > 0).OrderByDescending(h=>h.FBIllNO).ToList();
var tempList = SaleBILLLIS2Sa2.Where(h => h.FClient == t.FClient && h.FISHX != "已核销配对" && t.FDAMOUNT > 0).OrderByDescending(h => h.FBIllNO).ToList();
var FDAMOUNT = t.FDAMOUNT;
List<string> heTongList = new List<string>();
if (t.FCONTRACTNUMBER!=null)
if (t.FCONTRACTNUMBER != null)
heTongList = t.FCONTRACTNUMBER.Split(',').ToList().Distinct().ToList();
if(heTongList==null)
if (heTongList == null)
heTongList = new List<string>();
tempList.ForEach(sale =>
{
@@ -536,11 +558,11 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
if (str == null)
str = new List<string>();
str.Add(t.FBIllNO);
sale.FSKBIllNO = string.Join(",", str);
sale.FSKBIllNO = string.Join(",", str);
if (FDAMOUNT >= sale.FDAMOUNT)
{
benCi= sale.FDAMOUNT;
benCi = sale.FDAMOUNT;
sale.BenCi = sale.FDAMOUNT;
sale.FDAMOUNT = 0;
sale.FISHX = "已核销配对";
@@ -551,7 +573,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
sale.BenCi = FDAMOUNT;
sale.FDAMOUNT = sale.FDAMOUNT - benCi;
}
//sale.FYAMOUNT = sale.FYAMOUNT + sale.BenCi;
heTongList.Add(sale.FCONTRACTNUMBER);
heTongList = heTongList.Distinct().ToList();
@@ -567,17 +589,17 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FDAMOUNT = FDAMOUNT - sale.BenCi;
t.FDAMOUNT = t.FDAMOUNT - benCi;
//t.FYAMOUNT = t.FYAMOUNT + sale.BenCi;
t.BenCi = t.BenCi+benCi;
t.BenCi = t.BenCi + benCi;
t.FCONTRACTNUMBER = string.Join(",", heTongList);
if(heTongList.Count==1)
if (heTongList.Count == 1)
t.FWeiYi = "是";
else
t.FWeiYi = "否";
if (t.FDAMOUNT == 0)
{
t.FISHX = "已核销配对";
}
}
});
});
@@ -628,12 +650,12 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//this.View.Model.DeleteEntryData("FEntity");
#endregion
//获取已配对的数据
List<CombinaClass> SaleBILLLISNew2 = SaleBILLLISNew.Where(a => a.FSKBIllNO !="" && a.FSKBIllNO != null).ToList();
List<CombinaClass> SaleBILLLISNew2 = SaleBILLLISNew.Where(a => a.FSKBIllNO != "" && a.FSKBIllNO != null).ToList();
INDEXNumber = 1;
//绑定收款单数据
foreach (var item in ReceiveBILLLIST)
@@ -649,19 +671,19 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("F_PendingAmount", item.FDAMOUNT, item.FRow);
this.View.Model.SetValue("F_BenCi", item.BenCi, item.FRow);
this.View.Model.SetValue("F_MBBA_Decimal_3iy", item.FYAMOUNT, item.FRow);
this.View.Model.SetValue("F_ISHX",true, item.FRow);
this.View.Model.SetValue("F_ISHX", false, item.FRow);
List<string> strings = new List<string>();
if (item.FCONTRACTNUMBER != null)
strings = item.FCONTRACTNUMBER.Split(',').ToList();
strings = item.FCONTRACTNUMBER.Split(',').ToList();
var tempList2 = SaleBILLLISNew2.Where(h => strings.Contains(h.FCONTRACTNUMBER)).ToList();
var Rowindex = this.View.Model.GetEntryRowCount("FEntity2");
for (int i = 0; i < tempList2.Count; i++)
{
this.View.Model.SetValue("FPARENTROWID", FROWID, item.FRow);
this.View.Model.CreateNewEntryRow("FEntity2");
this.View.Model.SetValue("FROWID", Guid.NewGuid().ToString(), Rowindex+i);
this.View.Model.SetValue("FROWID", Guid.NewGuid().ToString(), Rowindex + i);
this.View.Model.SetValue("FPARENTROWID", FROWID, Rowindex + i);
this.View.Model.SetValue("FBILLNO2", tempList2[i].FBIllNO, Rowindex + i);
if (DateTime.TryParseExact(item?.FDate, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime parsedDate))
@@ -671,7 +693,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
else
{
this.View.Model.SetValue("FDate2", DateTime.Now.AddDays(-1 * Convert.ToInt32(item?.FDate)).ToString("yyyy-MM-dd"), Rowindex + i);
}
}
this.View.Model.SetValue("F_MBBA_Decimal_imu", tempList2[i].FALLAMOUNT, Rowindex + i);
this.View.Model.SetValue("FClient2", tempList2[i].FClient, Rowindex + i);
this.View.Model.SetValue("F_RowNew", 2, Rowindex + i);
@@ -679,16 +701,16 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
this.View.Model.SetValue("FCONTRACTNUMBER2", tempList2[i].FCONTRACTNUMBER, Rowindex + i);
this.View.Model.SetValue("FSalesman2", tempList2[i].FSalesman, Rowindex + i);
this.View.Model.SetValue("F_MBBA_Decimal_qtr", tempList2[i].FDAMOUNT, Rowindex + i);
this.View.Model.SetValue("F_PendingAmount", tempList2[i].FDAMOUNT, Rowindex + i);
double benci = shouKuanDetail[item.FBIllNO+","+ tempList2[i].FBIllNO];
double benci = shouKuanDetail[item.FBIllNO + "," + tempList2[i].FBIllNO];
this.View.Model.SetValue("F_BenCi", benci, Rowindex + i);
this.View.Model.SetValue("F_MBBA_Decimal_3iy", tempList2[i].FYAMOUNT, Rowindex + i);
this.View.Model.SetValue("F_ISHX", true, Rowindex + i);
this.View.Model.SetValue("F_ISHX", false, Rowindex + i);
}
//if (strings.Count() == 1 && item.FWeiYi == "否")
//{
@@ -759,10 +781,10 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
DynamicObjectCollection entryGrid2 = this.View.Model.DataObject["FEntity2"] as DynamicObjectCollection;
if (entryGrid != null)
{
var list = entryGrid2.Where(t => t["FCONTRACTNUMBER2"] != null && t["FCONTRACTNUMBER2"].ToString() != "" && t["F_RowNew"].ToString() =="1").ToList();
var list = entryGrid2.Where(t => t["FCONTRACTNUMBER2"] != null && t["FCONTRACTNUMBER2"].ToString() != "" && t["F_RowNew"].ToString() == "1").ToList();
foreach (var item in list)
{
entryGrid.ExpandedRow( int.Parse(item["SEQ"].ToString())-1);
entryGrid.ExpandedRow(int.Parse(item["SEQ"].ToString()) - 1);
}
//for (int i = 0; i < entryGrid2.Count; i++)
//{
@@ -783,7 +805,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
View.ShowMessage("确定要生成核销记录单吗?", MessageBoxOptions.YesNo, result =>
{
if (result == MessageBoxResult.Yes)
{
{
#region
//存储销售订单/应收单
@@ -800,7 +822,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
DynamicObjectCollection FEntity = this.View.Model.DataObject["FEntity"] as DynamicObjectCollection;
//获取收款单单据体数据
DynamicObjectCollection FEntity2 = this.View.Model.DataObject["FEntity2"] as DynamicObjectCollection;
var selectList = FEntity2.Where(t => t["F_ISHX"] != null && t["F_ISHX"].ToString().ToLower() == "true").ToList();
if (selectList.Count == 0 && selectList.Count == 0)
{
@@ -817,7 +839,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//return;
//this.View.Model.SetValue("FROWID", FROWID, RowindexNew);
//this.View.Model.SetValue("FPARENTROWID", FROWID, item.FRow);
var ReceiveBILLLIST2= selectList.Select(item=>new CombinaClass()
var ReceiveBILLLIST2 = selectList.Select(item => new CombinaClass()
{
FBIllNO = Convert.ToString(item["FBILLNO2"]),
FDate = Convert.ToString(item["FDate2"]),
@@ -833,23 +855,31 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
FWeiYi = item["FWeiYi2"]?.ToString(),
FRow = Convert.ToInt32(item["Seq"]),
F_RowNew = Convert.ToInt32(item["F_RowNew"]),
BenCi= Convert.ToDouble(item["BenCi"]),
FROWID= Convert.ToString(item["ROWID"]),
BenCi = Convert.ToDouble(item["BenCi"]),
FROWID = Convert.ToString(item["ROWID"]),
FPARENTROWID = Convert.ToString(item["PARENTROWID"]),
});
var shouKuanList = ReceiveBILLLIST2.Where(t => t.F_RowNew == 1).ToList();
List<string> errorList = new List<string>();
shouKuanList.ForEach(item=>
var eee = ReceiveBILLLIST2.Where(t => t.FDAMOUNT < t.BenCi).ToList();
if (eee.Count > 0)
{
var sales = ReceiveBILLLIST2.Where(t => t.FPARENTROWID == item.FROWID && t.FROWID!= item.FROWID).ToList();
string kk =string.Join(",", eee.Select(t => t.FBIllNO).ToList());
errorList.Add("这些订单的本次核销金额大于待核销金额"+ kk);
}
var shouKuanList = ReceiveBILLLIST2.Where(t => t.F_RowNew == 1).ToList();
shouKuanList.ForEach(item =>
{
var sales = ReceiveBILLLIST2.Where(t => t.FPARENTROWID == item.FROWID && t.FROWID != item.FROWID).ToList();
var heji = sales.Sum(t => t.BenCi);
if (heji != item.BenCi || heji==0 || sales.Count==0)
errorList.Add(item.FBIllNO+ $@" 明细={heji} 收款单={item.BenCi} ");
if (heji != item.BenCi || heji == 0 || sales.Count == 0)
errorList.Add(item.FBIllNO + $@" 明细={heji} 收款单={item.BenCi} ");
else
{
if (errorList.Count == 0)
{
{
//创建对象存储
var SKList = new CombinaAddSK();
@@ -857,7 +887,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
var stringSplit = sales.Select(t => t.FCONTRACTNUMBER).Distinct().ToList();
//找到对应销售订单
var nTestList = sales.Select(item2 => new CombinaAddClass1
var nTestList = sales.Select(item2 => new CombinaAddClass1
{
FBIllNO = item2.FBIllNO,
FClient = Convert.ToInt32(item2.FClient),
@@ -870,7 +900,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
});
SKList.XSAPList.AddRange(nTestList);
SKList.FBIllNO = item.FBIllNO;
SKList.FCONTRACTNUMBER =string.Join(",", sales.Select(t=>t.FCONTRACTNUMBER).Distinct().ToList());
SKList.FCONTRACTNUMBER = string.Join(",", sales.Select(t => t.FCONTRACTNUMBER).Distinct().ToList());
SKList.FClient = item.FClient;
SKList.FDate = item.FDate;
SKList.FALLAMOUNT = Convert.ToDecimal(item.BenCi);
@@ -879,7 +909,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
SKList.FSalesman = item.FSalesman;
fCombinaAddSK.Add(SKList);
}
}
});
@@ -888,25 +918,20 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
{
ErrMessage = true;
hetong = string.Join(",", errorList);
Message =string.Format($"收款单号:'{hetong}'的本次核销金额不等于勾选的销售订单的合计本次核销金额,不允许核销\r\n");
Message = string.Format($"收款单号:'{hetong}'的本次核销金额不等于勾选的销售订单的合计本次核销金额,不允许核销\r\n");
if (ErrMessage)
{
this.View.ShowErrMessage(Message);
}
}
return;
}
}
#endregion
//用于存储生成成功的收款单
List<string> strings1 = new List<string>();
List<string> successFbillNo = new List<string>();
int ISXSNUM = 0;
errorList = new List<string>();
//循环收款单/新增核销记录
@@ -930,7 +955,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
}
}
if (errorList.Count > 0)
Message = Message + " 有部分单失败,原因是:"+string.Join(",", errorList);
Message = Message + " 有部分单失败,原因是:" + string.Join(",", errorList);
this.View.ShowMessage(Message);
if (successFbillNo.Count > 0)
{
@@ -939,7 +964,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
var allRows = FEntity2.Where(t => pId.Contains(t["PARENTROWID"].ToString())).ToList();
allRows.ForEach(t =>
{
this.Model.DeleteEntryRow("FEntity2", Convert.ToInt32(t["Seq"])-1);
this.Model.DeleteEntryRow("FEntity2", Convert.ToInt32(t["Seq"]) - 1);
});
//tempRow.ForEach(item =>
//{
@@ -974,8 +999,8 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
// }
// }
// }
//}
//else
//{
@@ -989,6 +1014,8 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
});
}
}
#region DataChanged()
/// <summary>
/// 单据体值更新事件
@@ -1185,21 +1212,21 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
{
//获取销售订单/应收单单据体数据
DynamicObjectCollection FEntity2 = this.View.Model.DataObject["FEntity2"] as DynamicObjectCollection;
//获取当前复选框的值
var IsHX = this.Model.GetValue("F_ISHX", e.Row)?.ToString();
var F_RowNew = this.Model.GetValue("F_RowNew", e.Row)?.ToString();
if (F_RowNew != "1")
return;
string PARENTROWID= this.Model.GetValue("FPARENTROWID", e.Row)?.ToString();
string PARENTROWID = this.Model.GetValue("FPARENTROWID", e.Row)?.ToString();
var dataRow = FEntity2.Where(item => item["PARENTROWID"].ToString() == PARENTROWID && int.Parse(item["F_RowNew"].ToString()) != 1).ToList();
if (IsHX.ToLower() == "true" && dataRow.Where(t => t["F_ISHX"].ToString().ToLower() == "true").Count() > 0)
{
return;
}
dataRow.ForEach(item=>
dataRow.ForEach(item =>
{
this.Model.SetValue("F_ISHX", IsHX, int.Parse(item["SEQ"].ToString())-1);
this.Model.SetValue("F_ISHX", IsHX, int.Parse(item["SEQ"].ToString()) - 1);
//this.Model.SetValue("F_ISGX", "False", i);
});
//查询对应的销售订单/应收单-》勾选复选框
@@ -1222,7 +1249,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//}
//if (IsHX == "False")
//{
// int n = 0;
// //判断其他收款单是否勾选
// foreach (var item in FEntity2)
@@ -1262,5 +1289,183 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
ExpandWaiting = 64,///0000 0100 0000包含展开等待数据请求行
Summary = 128///0001 0000 000汇总类型数据行 
}
public void FilterCallBack(FormResult action)
{
if (action.ReturnData != null)
{
FilterParameter returnData = action.ReturnData as FilterParameter;//过滤框返回的数据
DynamicObject dyObj = returnData.CustomFilter as DynamicObject;
//获取组织FID
DynamicObject FSaleOrg = dyObj["F_ZhuZhi2"] as DynamicObject;
string FSaleOrgId = "";
string where1 = " and 1=1";
string where2 = " and 1=1";
if (FSaleOrg != null)
{
FSaleOrgId = Convert.ToString(FSaleOrg["ID"]);
where1 += $@" AND A.FSALEORGID = {FSaleOrgId}";
where2 += $@" AND A.FSALEORGID = {FSaleOrgId}";
}
////获取客户单位
//DynamicObject CUST = dyObj["FClient"] as DynamicObject;
//string CustFid = "";
//if (CUST != null)
//{
// CustFid = Convert.ToString(CUST["ID"]);
// where1 += $@" and A.FCUSTID = '{CustFid}'";
// where2 += $@" and A.FCONTACTUNIT = '{CustFid}'";
//}
//获取多选客户单位
var ZZS = returnData.CustomFilter["FClientList"] as DynamicObjectCollection;
string CustFid = "";
if (ZZS.Count > 0)
{
List<string> zzList = new List<string>();
//循环获取多选组织FID
foreach (DynamicObject dobj in ZZS)
{
DynamicObject dynamic = dobj["FClientList"] as DynamicObject;
zzList.Add(dynamic["ID"].ToString());
}
CustFid = string.Join("','", zzList);
where1 += $@" and A.FCUSTID in ('{CustFid}')";
where2 += $@" and A.FCONTACTUNIT in ('{CustFid}')";
}
//获取收款日期
var FSDate = Convert.ToString(dyObj["F_ShouKuan1"]);
if (!string.IsNullOrWhiteSpace(FSDate))
{
where2 += $@" and A.FDATE >='{FSDate}'";
}
//获取收款结束日期
var FEDate = Convert.ToString(dyObj["F_ShouKuan2"]);
if (!string.IsNullOrWhiteSpace(FEDate))
{
DateTime end = DateTime.Parse(FEDate).Date.AddDays(1);
where2 += $@" and A.FDATE < '{end}'";
}
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");
this.View.Model.DeleteEntryData("FEntity2");
//var FShuaXin = this.View.Model.GetValue("FShuaXin");
//调用SQL获取数据
var WriteOrderDate = SQL.SqlManage_yuyubo.GetWriteOrderDate3(this.Context, FSaleOrgId, where1);
var WriteReceiveDate = SQL.SqlManage_yuyubo.GetWriteReceiveDate3(this.Context, FSaleOrgId, where2);
SaleBILLLIS = WriteOrderDate.Select(item => new CombinaClass
{
Fid = Convert.ToInt32(item["FID"]),
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"]),
BenCi = Convert.ToDouble(item["BenCi"]),
F_Ordercategory2 = Convert.ToString(item["F_Ordercategory2"]),
F_Ordercategory = Convert.ToString(item["F_Ordercategory"]),
FInvoiceAmount = Convert.ToDecimal(item["FInvoiceAmount"]),
}).ToList();
ReceiveBILLLIST = WriteReceiveDate.Select(item => new CombinaClass
{
Fid = Convert.ToInt32(item["FID"]),
FBIllNO = Convert.ToString(item["FBIllNO"]),
FDate = Convert.ToString(item["FDate"]),
FALLAMOUNT = Convert.ToDouble(item["FALLAMOUNT"]),
FYAMOUNT = Convert.ToDouble(item["FYAMOUNT"]),
FDAMOUNT = Convert.ToDouble(item["FDAMOUNT"]),
FClient = Convert.ToInt32(item["FCONTACTUNIT"]),
FCreated = Convert.ToInt32(item["FCREATORID"]),
FRemark = Convert.ToString(item["FREMARK"]),
FSalesman = Convert.ToInt32(item["FSALEERID"]),
F_RowNew = 1,
BenCi = 0,
}).ToList();
var kehu = ReceiveBILLLIST.Select(t => t.FClient).Distinct().ToList();
SaleBILLLIS = SaleBILLLIS.Where(t => kehu.Contains(t.FClient)).ToList();
SaleBILLLIS2 = SaleBILLLIS.ToList();
//绑定销售订单数据
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.Model.SetValue("F_Ordercategory2", SaleBILLLIS2[i].F_Ordercategory2, i);
this.View.Model.SetValue("F_Ordercategory", SaleBILLLIS2[i].F_Ordercategory, i);
this.View.Model.SetValue("FInvoiceAmount", SaleBILLLIS2[i].FInvoiceAmount, i);
}
this.View.UpdateView("FEntity");
for (int i = 0; i < ReceiveBILLLIST.Count; i++)
{
int Rowindex = this.View.Model.GetEntryRowCount("FEntity2");
int RowindexNew = Rowindex;
this.View.Model.CreateNewEntryRow("FEntity2");
string FROWID = SequentialGuid.NewGuid().ToString();
this.View.Model.SetValue("FROWID", FROWID, RowindexNew);
this.View.Model.SetValue("FPARENTROWID", FROWID, RowindexNew);
this.View.Model.SetValue("FBILLNO2", ReceiveBILLLIST[i].FBIllNO, RowindexNew);
this.View.Model.SetValue("F_BenCi", ReceiveBILLLIST[i].BenCi, RowindexNew);
this.View.Model.SetValue("F_PendingAmount", ReceiveBILLLIST[i].FDAMOUNT, RowindexNew);
this.View.Model.SetValue("FDATE2", DateTime.Now.AddDays(-1 * Convert.ToInt32(ReceiveBILLLIST[i].FDate)).ToString("yyyy-MM-dd"), RowindexNew);
this.View.Model.SetValue("F_MBBA_Decimal_imu", ReceiveBILLLIST[i].FALLAMOUNT, RowindexNew);
this.View.Model.SetValue("FClient2", ReceiveBILLLIST[i].FClient, RowindexNew);
this.View.Model.SetValue("FRemark", ReceiveBILLLIST[i].FRemark, RowindexNew);
this.View.Model.SetValue("F_MBBA_Decimal_3iy", ReceiveBILLLIST[i].FYAMOUNT, RowindexNew);
this.View.Model.SetValue("F_MBBA_Decimal_lsn", ReceiveBILLLIST[i].FDAMOUNT, RowindexNew);
this.View.Model.SetValue("FCreated2", ReceiveBILLLIST[i].FCreated, RowindexNew);
this.View.Model.SetValue("FSalesman2", ReceiveBILLLIST[i].FSalesman, RowindexNew);
this.View.Model.SetValue("F_RowNew", ReceiveBILLLIST[i].F_RowNew, RowindexNew);
this.View.Model.SetValue("F_ISHX", false, RowindexNew);
}
this.View.UpdateView("FEntity2");
}
}
}
}