trycath
This commit is contained in:
parent
d308b464a1
commit
4177536514
@ -23,210 +23,215 @@ namespace Pilot_KD_Parino.Sal_Order
|
|||||||
|
|
||||||
public override void BeforeDoSaveExecute(BeforeDoSaveExecuteEventArgs e)
|
public override void BeforeDoSaveExecute(BeforeDoSaveExecuteEventArgs e)
|
||||||
{
|
{
|
||||||
base.BeforeDoSaveExecute(e);
|
try
|
||||||
var FEntity = e.DataEntities[0];
|
|
||||||
var FNAME1 = FEntity["BillTypeId_Id"].ToString();
|
|
||||||
string yuanF_contractnumber = FEntity["F_contractnumber"].ToString();
|
|
||||||
if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null)
|
|
||||||
{
|
{
|
||||||
|
base.BeforeDoSaveExecute(e);
|
||||||
var json = JsonUtil.Serialize(FEntity);
|
var FEntity = e.DataEntities[0];
|
||||||
//Logger.Error("销售订单保存前刷正确的合同号", json, new Exception());
|
var FNAME1 = FEntity["BillTypeId_Id"].ToString();
|
||||||
var fid = FEntity["id"];
|
|
||||||
|
|
||||||
var sql3333 = $@"SELECT F_contractnumber FROM dbo.T_SAL_ORDER WHERE fid={fid} and F_contractnumber !='' ";
|
if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null)
|
||||||
var sqlDS33 = DBUtils.ExecuteDynamicObject(this.Context, sql3333);
|
|
||||||
if (sqlDS33 != null && sqlDS33.Count > 0)
|
|
||||||
{
|
|
||||||
string contractnumber = sqlDS33[0]["F_contractnumber"].ToString();
|
|
||||||
//Logger.Error("销售订单保存前刷正确的合同号2", contractnumber, new Exception());
|
|
||||||
FEntity["F_contractnumber"] = contractnumber;
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
|
||||||
var formID = FEntity["FFormId"];
|
var json = JsonUtil.Serialize(FEntity);
|
||||||
//销售订单新变更单
|
//Logger.Error("销售订单保存前刷正确的合同号", json, new Exception());
|
||||||
if (formID.ToString() == "SAL_XORDER")
|
var fid = FEntity["id"];
|
||||||
|
|
||||||
|
var sql3333 = $@"SELECT F_contractnumber FROM dbo.T_SAL_ORDER WHERE fid={fid} and F_contractnumber !='' ";
|
||||||
|
var sqlDS33 = DBUtils.ExecuteDynamicObject(this.Context, sql3333);
|
||||||
|
if (sqlDS33 != null && sqlDS33.Count > 0)
|
||||||
{
|
{
|
||||||
|
string contractnumber = sqlDS33[0]["F_contractnumber"].ToString();
|
||||||
|
//Logger.Error("销售订单保存前刷正确的合同号2", contractnumber, new Exception());
|
||||||
|
FEntity["F_contractnumber"] = contractnumber;
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var formID = FEntity["FFormId"];
|
||||||
|
//销售订单新变更单
|
||||||
|
if (formID.ToString() == "SAL_XORDER")
|
||||||
{
|
{
|
||||||
var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection;
|
return;
|
||||||
if (FSaleOrderEntry_Link.Count > 0)
|
if (FNAME1.ToString() == "a300e2620037435492aed9842875b451" && FNAME1 != null)
|
||||||
{
|
{
|
||||||
var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection;
|
var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection;
|
||||||
//var FbiLLNO = this.View.Model.GetValue("FBILLNO");
|
if (FSaleOrderEntry_Link.Count > 0)
|
||||||
|
|
||||||
if (details != null)
|
|
||||||
{
|
{
|
||||||
var entrys = details;
|
var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection;
|
||||||
if (entrys != null && entrys.Count > 0)
|
//var FbiLLNO = this.View.Model.GetValue("FBILLNO");
|
||||||
|
|
||||||
|
if (details != null)
|
||||||
{
|
{
|
||||||
foreach (var entry in entrys)
|
var entrys = details;
|
||||||
|
if (entrys != null && entrys.Count > 0)
|
||||||
{
|
{
|
||||||
|
string yuanF_contractnumber = FEntity["F_contractnumber"].ToString();
|
||||||
var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int();
|
foreach (var entry in entrys)
|
||||||
|
|
||||||
//获取退货类型字段
|
|
||||||
var F_Returntype = FEntity["F_Returntype"];
|
|
||||||
|
|
||||||
//获取纸质合同号
|
|
||||||
String F_contractnumber = FEntity["F_contractnumber"].ToString();
|
|
||||||
//string yuanF_contractnumber = F_contractnumber;
|
|
||||||
int dashPosition;
|
|
||||||
if (F_contractnumber.Contains("-TH"))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
dashPosition = F_contractnumber.IndexOf("-TH");
|
var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int();
|
||||||
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
|
||||||
}
|
//获取退货类型字段
|
||||||
else if (F_contractnumber.Contains("-HH"))
|
var F_Returntype = FEntity["F_Returntype"];
|
||||||
{
|
|
||||||
dashPosition = F_contractnumber.IndexOf("-HH");
|
//获取纸质合同号
|
||||||
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
String F_contractnumber = FEntity["F_contractnumber"].ToString();
|
||||||
}
|
|
||||||
else
|
int dashPosition;
|
||||||
{
|
if (F_contractnumber.Contains("-TH"))
|
||||||
dashPosition = -2;
|
{
|
||||||
}
|
|
||||||
var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}'AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId);
|
dashPosition = F_contractnumber.IndexOf("-TH");
|
||||||
var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql);
|
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
||||||
String F_contractnumber2 = FEntity["F_contractnumber"].ToString();
|
}
|
||||||
int number;
|
else if (F_contractnumber.Contains("-HH"))
|
||||||
if (F_contractnumber2.Contains("-") && dashPosition != -2)
|
{
|
||||||
{
|
dashPosition = F_contractnumber.IndexOf("-HH");
|
||||||
number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int();
|
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
number = sqlDS[0]["FNUMBER"].Long2Int();
|
dashPosition = -2;
|
||||||
number += 1;
|
}
|
||||||
//if (number == 1)
|
var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}'AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId);
|
||||||
|
var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql);
|
||||||
|
String F_contractnumber2 = FEntity["F_contractnumber"].ToString();
|
||||||
|
int number;
|
||||||
|
if (F_contractnumber2.Contains("-") && dashPosition != -2)
|
||||||
|
{
|
||||||
|
number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
number = sqlDS[0]["FNUMBER"].Long2Int();
|
||||||
|
number += 1;
|
||||||
|
//if (number == 1)
|
||||||
|
//{
|
||||||
|
// number += 1;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
string F_contractnumber1;
|
||||||
|
|
||||||
|
int IFnumber = sqlDS[0]["FNUMBER"].Long2Int();
|
||||||
|
|
||||||
|
if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString();
|
||||||
|
FEntity["F_contractnumber"] = F_contractnumber1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!F_Returntype.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1';
|
||||||
|
|
||||||
|
FEntity["F_contractnumber"] = F_contractnumber1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//else if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty())
|
||||||
//{
|
//{
|
||||||
// number += 1;
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string F_contractnumber1;
|
|
||||||
|
|
||||||
int IFnumber = sqlDS[0]["FNUMBER"].Long2Int();
|
|
||||||
|
|
||||||
if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString();
|
|
||||||
FEntity["F_contractnumber"] = F_contractnumber1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!F_Returntype.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1';
|
|
||||||
|
|
||||||
FEntity["F_contractnumber"] = F_contractnumber1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//else if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty())
|
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//销售订单
|
||||||
//销售订单
|
else if (formID.ToString() == "SAL_SaleOrder")
|
||||||
else if (formID.ToString() == "SAL_SaleOrder")
|
|
||||||
{
|
|
||||||
var FNAME = FEntity["BillTypeId_Id"].ToString();
|
|
||||||
if (FNAME == "a300e2620037435492aed9842875b451" && FNAME != null)
|
|
||||||
{
|
{
|
||||||
var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection;
|
var FNAME = FEntity["BillTypeId_Id"].ToString();
|
||||||
if (FSaleOrderEntry_Link.Count > 0)
|
if (FNAME == "a300e2620037435492aed9842875b451" && FNAME != null)
|
||||||
{
|
{
|
||||||
var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection;
|
var FSaleOrderEntry_Link = FEntity["SaleOrderEntry"] as DynamicObjectCollection;
|
||||||
string sdas=JsonHelper.ToJson(details);
|
if (FSaleOrderEntry_Link.Count > 0)
|
||||||
Logger.Error("销售订单上游订单的xx ", sdas, new Exception());
|
|
||||||
//var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry_Link");
|
|
||||||
//var FbiLLNO = this.View.Model.GetValue("FID");
|
|
||||||
|
|
||||||
if (details != null)
|
|
||||||
{
|
{
|
||||||
var entrys = details;
|
var details = FSaleOrderEntry_Link[0]["FSaleOrderEntry_Link"] as DynamicObjectCollection;
|
||||||
|
//string sdas=JsonHelper.ToJson(details);
|
||||||
|
// Logger.Error("销售订单上游订单的xx ", sdas, new Exception());
|
||||||
|
//var details = this.View.BusinessInfo.GetEntity("FSaleOrderEntry_Link");
|
||||||
|
//var FbiLLNO = this.View.Model.GetValue("FID");
|
||||||
|
|
||||||
if (entrys != null && entrys.Count > 0)
|
if (details != null)
|
||||||
{
|
{
|
||||||
int i = 0;
|
var entrys = details;
|
||||||
foreach (var entry in entrys)
|
|
||||||
|
if (entrys != null && entrys.Count > 0)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
string yuanF_contractnumber = FEntity["F_contractnumber"].ToString();
|
||||||
return;
|
int i = 0;
|
||||||
i++;
|
foreach (var entry in entrys)
|
||||||
|
|
||||||
var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int();
|
|
||||||
|
|
||||||
//获取退货类型字段
|
|
||||||
var F_Returntype = FEntity["F_Returntype"];
|
|
||||||
|
|
||||||
//获取纸质合同号
|
|
||||||
string F_contractnumber = FEntity["F_contractnumber"].ToString();
|
|
||||||
|
|
||||||
Logger.Error("销售订单上游订单的合同号", yuanF_contractnumber, new Exception());
|
|
||||||
int dashPosition;
|
|
||||||
if (F_contractnumber.Contains("-TH"))
|
|
||||||
{
|
{
|
||||||
|
if (i > 0)
|
||||||
|
return;
|
||||||
|
i++;
|
||||||
|
|
||||||
dashPosition = F_contractnumber.IndexOf("-TH");
|
var sBillId = entry == null ? 0 : entry["sBillId"].Long2Int();
|
||||||
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
|
||||||
}
|
|
||||||
else if (F_contractnumber.Contains("-HH"))
|
|
||||||
{
|
|
||||||
dashPosition = F_contractnumber.IndexOf("-HH");
|
|
||||||
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dashPosition = -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}' AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId);
|
//获取退货类型字段
|
||||||
var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql);
|
var F_Returntype = FEntity["F_Returntype"];
|
||||||
string F_contractnumber2 = F_contractnumber;
|
|
||||||
int number;
|
|
||||||
if (F_contractnumber2.Contains("-") && dashPosition != -2)
|
|
||||||
{
|
|
||||||
number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number = sqlDS[0]["FNUMBER"].Long2Int();
|
|
||||||
number += 1;
|
|
||||||
//if (number == 1)
|
|
||||||
//{
|
|
||||||
// number += 1;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
string F_contractnumber1;
|
//获取纸质合同号
|
||||||
|
string F_contractnumber = FEntity["F_contractnumber"].ToString();
|
||||||
|
|
||||||
int IFnumber = sqlDS[0]["FNUMBER"].Long2Int();
|
Logger.Error("销售订单上游订单的合同号", yuanF_contractnumber, new Exception());
|
||||||
|
int dashPosition;
|
||||||
|
if (F_contractnumber.Contains("-TH"))
|
||||||
|
{
|
||||||
|
|
||||||
if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty())
|
dashPosition = F_contractnumber.IndexOf("-TH");
|
||||||
{
|
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
||||||
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString();
|
}
|
||||||
FEntity["F_contractnumber"]= F_contractnumber1;
|
else if (F_contractnumber.Contains("-HH"))
|
||||||
break;
|
{
|
||||||
}
|
dashPosition = F_contractnumber.IndexOf("-HH");
|
||||||
else if (!F_Returntype.IsNullOrEmpty() )
|
F_contractnumber = dashPosition > -1 ? F_contractnumber.Substring(0, dashPosition) : F_contractnumber;
|
||||||
{
|
}
|
||||||
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1';
|
else
|
||||||
FEntity["F_contractnumber"] = F_contractnumber1;
|
{
|
||||||
break;
|
dashPosition = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sql = string.Format(@"SELECT COUNT(*) AS FNUMBER FROM T_SAL_ORDERENTRY_LK WHERE FSBILLID = '{0}' AND FRULEID = 'SaleOrder-ReturnSaleOrder'", sBillId);
|
||||||
|
var sqlDS = DBUtils.ExecuteDynamicObject(this.Context, sql);
|
||||||
|
string F_contractnumber2 = F_contractnumber;
|
||||||
|
int number;
|
||||||
|
if (F_contractnumber2.Contains("-") && dashPosition != -2)
|
||||||
|
{
|
||||||
|
number = F_contractnumber2.Substring(F_contractnumber2.Length - 2).Long2Int();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
number = sqlDS[0]["FNUMBER"].Long2Int();
|
||||||
|
number += 1;
|
||||||
|
//if (number == 1)
|
||||||
|
//{
|
||||||
|
// number += 1;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
string F_contractnumber1;
|
||||||
|
|
||||||
|
int IFnumber = sqlDS[0]["FNUMBER"].Long2Int();
|
||||||
|
|
||||||
|
if (IFnumber != 0 && !F_Returntype.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + number.ToString();
|
||||||
|
FEntity["F_contractnumber"] = F_contractnumber1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!F_Returntype.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
F_contractnumber1 = yuanF_contractnumber.ToString() + '-' + F_Returntype + '0' + '1';
|
||||||
|
FEntity["F_contractnumber"] = F_contractnumber1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,6 +241,10 @@ namespace Pilot_KD_Parino.Sal_Order
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error("销售订单保存前刷正确的合同号报错:", ex.Message, new Exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public override void BeforeUpdateValue(BeforeUpdateValueEventArgs e)
|
//public override void BeforeUpdateValue(BeforeUpdateValueEventArgs e)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user