using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
using Kingdee.BOS.WebApi.Client;
|
|
namespace BLL
|
{
|
public class ClsKf_SellOutBackBill
|
{
|
/// <summary>
|
/// 根据过滤条件,返回源单信息-销售出库单-蓝字列表(红字销售出库源单)
|
/// </summary>
|
/// <param name="sWhere">过滤条件</param>
|
/// <param name="sErr">错误信息</param>
|
/// <returns></returns>
|
public DataSet GetKf_SellOutBillList(string sWhere, ref string sErr)
|
{
|
try
|
{
|
DAL.Cls_S_IF_SellOutBill_Lite dal = new DAL.Cls_S_IF_SellOutBill_Lite();
|
return dal.DisSourceBillList(sWhere);
|
}
|
catch (Exception e)
|
{
|
sErr = sErr + "," + e.Message;
|
return null;
|
}
|
}
|
|
/// <summary>
|
/// 根据过滤条件,返回源单信息-退货通知单列表 (红字销售出库源单)
|
/// </summary>
|
/// <param name="sWhere">过滤条件</param>
|
/// <param name="sErr">错误信息</param>
|
/// <returns></returns>
|
public DataSet GetXs_SeOutStockBackBillList(string sWhere, ref string sErr)
|
{
|
try
|
{
|
DAL.Cls_S_IF_SeOutStockBackBill_Lite dal = new DAL.Cls_S_IF_SeOutStockBackBill_Lite();
|
return dal.DisSourceBillList(sWhere);
|
}
|
catch (Exception e)
|
{
|
sErr = sErr + "," + e.Message;
|
return null;
|
}
|
}
|
|
/// <summary>
|
/// 根据过滤条件,返回源单信息-销售订单列表
|
/// </summary>
|
/// <param name="sWhere">过滤条件</param>
|
/// <param name="sErr">错误信息</param>
|
/// <returns></returns>
|
public DataSet GetXs_SeOrderBackBillList(string sWhere, ref string sErr)
|
{
|
//try
|
//{
|
// DAL.Cls_S_IF_SEOrderBackBill_Lite dal = new DAL.Cls_S_IF_SEOrderBackBill_Lite();
|
// return dal.DisSourceBillList(sWhere);
|
//}
|
//catch (Exception e)
|
//{
|
// sErr = sErr + "," + e.Message;
|
return null;
|
//}
|
}
|
|
|
//生成销售退库单
|
public bool set_SaveSellOutBackBill_New(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, ref string sErrMsg)
|
{
|
//获取系统参数
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
if (oSystemParameter.ShowBill(ref sErrMsg) == false)
|
{
|
sErrMsg = "获取系统参数失败! " + sErrMsg;
|
return false;
|
}
|
//
|
if (oSystemParameter.omodel.Kf_SellOutBackBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE
|
{
|
if (SaveSellOutBackBill_K3(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg))
|
{
|
//"保存成功!";
|
sErrMsg = "保存成功!" + oMain.HBillNo;
|
return true;
|
}
|
else
|
{
|
//"保存失败!";
|
sErrMsg = sErrMsg;
|
return false;
|
}
|
}
|
if (oSystemParameter.omodel.Kf_SellOutBackBill_ERPMode.ToUpper() == "CLOUD") //判断同步模式是金蝶CLOUD
|
{
|
if (set_SaveSellOutBackBill_CLD(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg) == true)
|
{
|
//"保存成功!";
|
return true;
|
}
|
else
|
{
|
//"保存失败!";
|
return false;
|
}
|
}
|
|
sErrMsg = "保存销售退库单失败!" + sErrMsg;
|
return false;
|
}
|
|
|
|
#region 销售退库K3 销售出库(红字) *
|
|
/// <summary>
|
/// 生成销售退库单K3
|
/// </summary>
|
/// <param name="oMain"></param>
|
/// <param name="sErrMsg"></param>
|
/// <returns></returns>
|
public bool SaveSellOutBackBill_K3(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DAL.ClsKf_SellOutBackBill dal = new DAL.ClsKf_SellOutBackBill();
|
dal.omodel = oMain;
|
//上传前必填项判断
|
if (oMain.HDeptID == 0)
|
{
|
sErrMsg = "部门没有选择!";
|
return false;
|
}
|
if (oMain.HSupID == 0)
|
{
|
sErrMsg = "客户没有选择!";
|
return false;
|
}
|
if (oMain.HSecManagerID == 0)
|
{
|
sErrMsg = "收货没有选择!";
|
return false;
|
}
|
if (oMain.HKeeperID == 0)
|
{
|
sErrMsg = "保管没有选择!";
|
return false;
|
}
|
|
try
|
{
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oMain.HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
sErrMsg = s;
|
return false;
|
}
|
oMain.HYear = sYear;
|
oMain.HPeriod = sPeriod;
|
|
DataSet Ds;
|
oCn.BeginTran();
|
//生成出入库单据
|
//插入子表
|
oCn.RunProc("EXEC h_p_Kf_SellOutBackBillSub_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
|
//插入主表
|
oCn.RunProc("Insert Into Kf_ICStockBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
|
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
|
",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
|
",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
|
") " +
|
" values('1247','1247'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
|
", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
|
", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
|
", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
|
") ");
|
|
//新增K3子表、主表
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'," + oMain.HBillerID.ToString() + ",'" + sHSourceType + "'");
|
|
//更新关联数量
|
if (sHSourceType == "1403") //退货通知单
|
{
|
oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOutStockBackToSellOutBack_Add " + oMain.HInterID.ToString());
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_UpdateBillRelateData_SeOutStockBack " + oMain.HInterID.ToString());
|
}
|
else if (sHSourceType == "1205") //销售出库单-蓝字
|
{
|
oCn.RunProc("exec h_p_Kf_UpDateRelation_SellOutToSellOutBack_Add " + oMain.HInterID.ToString());
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_UpdateBillRelateData_Blue " + oMain.HInterID.ToString());
|
}
|
else if (sHSourceType == "1401") //销售订单
|
{
|
oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellOutBack_Add " + oMain.HInterID.ToString());
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_UpdateBillRelateData_SeOrder " + oMain.HInterID.ToString());
|
}
|
else //无源单
|
{
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_UpdateBillRelateData " + oMain.HInterID.ToString());
|
}
|
|
//审核单据
|
if (oSystemParameterMain.Kf_SellOutBackBill_AutoCheck == "Y") //系统参数 自动审核
|
{
|
//审核单据
|
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
|
|
//审核K3单据
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_Check " + oMain.HInterID.ToString() + "," + oMain.HBillerID.ToString());
|
//更新K3库存
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_UpdateStock " + oMain.HInterID.ToString());
|
oCn.RunProc("exec h_p_IFK3_ToERP_SellOutBackBill_UpdateOrderStock " + oMain.HInterID.ToString());
|
}
|
|
//同步生成外购退料单
|
if (oSystemParameterMain.Kf_SellOutBackBill_AutoSavePOStockInBackBill == "Y") //系统参数 同步生成外购退料单
|
{
|
//判断所登录用户账号是否绑定了对应供应商
|
DataSet Ds2 = oCn.RunProcReturn(" select HSupID from Gy_Czygl where Czymc= '" + oMain.HMaker + "'", "Gy_Czygl");
|
if (Ds2 == null || Ds2.Tables[0].Rows.Count == 0)
|
{
|
sErrMsg = "所登录用户账号不正确,请重新登录!";
|
oCn.RollBack();
|
return false;
|
}
|
else if (DBUtility.ClsPub.isLong(Ds2.Tables[0].Rows[0]["HSupID"]) == 0)
|
{
|
sErrMsg = "所登录用户账号没有绑定对应供应商,无法同步生成外购退料单,生成单据失败,请先设置对应供应商!";
|
oCn.RollBack();
|
return false;
|
}
|
long HNewInterID = DBUtility.ClsPub.CreateBillID_Prod("1239", ref sErrMsg);
|
string HNewBillNo = DBUtility.ClsPub.CreateBillCode_Prod("1239", ref sErrMsg, true);
|
string HNewSourceType = "-1"; //无源单
|
//新增ERP子表、主表
|
oCn.RunProc("exec h_p_Kf_SellOutBackBill_AutoSavePOStockInBackBill " + oMain.HInterID.ToString() + "," + HNewInterID + ",'" + HNewBillNo + "'");
|
//新增K3子表、主表
|
oCn.RunProc("exec h_p_IFK3_ToERP_POStockInBackBill_Insert_New " + HNewInterID + ",'" + HNewBillNo + "'," + oMain.HBillerID.ToString() + ",'" + HNewSourceType + "'");
|
//回填K3关联数量
|
oCn.RunProc("exec h_p_IFK3_ToERP_POStockInBackBill_UpdateBillRelateData " + HNewInterID);
|
//审核单据
|
if (oSystemParameterMain.Kf_POStockInBackBill_AutoCheck == "Y") //系统参数 自动审核
|
{
|
//审核单据
|
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + HNewInterID);
|
//审核K3单据
|
oCn.RunProc("exec h_p_IFK3_ToERP_POStockInBackBill_Check " + HNewInterID + "," + oMain.HBillerID.ToString());
|
//更新K3库存
|
oCn.RunProc("exec h_p_IFK3_ToERP_POStockInBackBill_UpdateStock " + HNewInterID);
|
oCn.RunProc("exec h_p_IFK3_ToERP_POStockInBackBill_UpdateOrderStock " + HNewInterID);
|
}
|
|
//K3负库存判断
|
if (oSystemParameterMain.WMS_ERPStockCtl == "Y") //系统参数 提交后ERP负库存控制
|
{
|
//判断条码库存是否异常(负库存、库存大于条码初始化)
|
Ds = oCn.RunProcReturn("EXEC h_p_KF_ICInventoryBarCodeQtyCtrl " + oMain.HInterID.ToString(), "h_p_KF_ICInventoryBarCodeQtyCtrl");
|
if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) == 1)
|
{
|
|
}
|
else
|
{
|
sErrMsg = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][1]);
|
oCn.RollBack();
|
return false;
|
}
|
}
|
}
|
|
sErrMsg = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sErrMsg = "生成销售退库单失败!" + e.Message;
|
oCn.RollBack();
|
return false;
|
}
|
}
|
|
#endregion
|
|
#region 销售退货CLOUD 销售出库(红字) *
|
|
public bool set_SaveSellOutBackBill_CLD(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
|
{
|
if (sHSourceType == "1403") //退货通知单
|
{
|
if (SaveSellOutBackBill_SeOutStockBack_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
|
{
|
//"保存成功!";
|
sErrMsg = "保存成功!" + oMain.HBillNo + sErrMsg;
|
return true;
|
}
|
else
|
{
|
//"保存失败!";
|
sErrMsg = sErrMsg;
|
return false;
|
}
|
}
|
else
|
{
|
sErrMsg = "错误的源单类型";
|
return false;
|
}
|
}
|
|
|
private bool SaveSellOutBackBill_SeOutStockBack_CLD(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
DataSet Ds;
|
//
|
oCn.BeginTran();
|
//写入WMS销售退货单
|
|
//插入子表
|
oCn.RunProc("EXEC h_p_Kf_SellOutBackBillSub_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + sHSourceType + "'");
|
//插入主表
|
oCn.RunProc("Insert Into Kf_ICStockBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
|
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
|
",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
|
",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
|
") " +
|
" values('1247','1247'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
|
", " + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + ",'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
|
", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
|
", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
|
") ");
|
//更新关联数量
|
oCn.RunProc("exec h_p_Xs_UpDateRelation_SeOutStockBackToSellOutBack_Add " + oMain.HInterID.ToString());
|
|
if (oSystemParameterMain.Kf_SellOutBackBill_AutoCheck == "Y") //系统参数 自动审核
|
{
|
//审核单据
|
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
|
}
|
|
//根据TMP表 返回 子表信息
|
Ds = oCn.RunProcReturn("exec h_p_Kf_GetSellOutBackBill_SeOutStockBack_CLD " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetSellOutBackBill_SeOutStockBack_CLD");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
|
{
|
sErrMsg = "获取子表信息失败!";
|
oCn.RollBack();
|
return false;
|
}
|
else
|
{
|
string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\", " +
|
"\"IsEntryBatchFill\":\"True\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\",\"Model\":{" +
|
//\"FID\":" + oMain.HInterID.ToString() + "," +
|
"\"FBillTypeID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\" }," +
|
"\"FBillNo\":\"" + oMain.HBillNo + "\"," +
|
//"\"FDate\":\"" + oMain.HDate .ToShortDateString()+ "\"," +
|
"\"FSALEORGID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEORGID"]) + "\" }," +
|
"\"FRETCUSTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRETCUSTID"]) + "\" }," +
|
"\"FSALEDEPTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEDEPTID"]) + "\" }," +
|
"\"FRETURNREASON\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRETURNREASON"]) + "\" }," +
|
"\"FHEADLOCID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FHEADLOCID"]) + "\" }," +
|
//"FCorrespondOrgId": {"FNumber": ""},
|
"\"FTransferBizType\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferBizType"]) + "\" }," +
|
"\"FSALEGROUPID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALEGROUPID"]) + "\" }," +
|
"\"FSALESMANID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSALESMANID"]) + "\" }," +
|
"\"FSTOCKORGID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKORGID"]) + "\" }," +
|
"\"FSTOCKDEPTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKDEPTID"]) + "\" }," +
|
"\"FSTOCKERGROUPID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKERGROUPID"]) + "\" }," +
|
"\"FSTOCKERID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSTOCKERID"]) + "\" }," +
|
"\"FHeadNote\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FNOTE"]) + "\"," +
|
"\"FRECEIVECUSTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRECEIVECUSTID"]) + "\" }," +
|
"\"FRECEIVEADDRESS\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRECEIVEADDRESS"]) + "\"," +
|
"\"FSETTLECUSTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLECUSTID"]) + "\" }," +
|
//"FReceiveCusContact": {"FNAME": ""},
|
"\"FPAYCUSTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPAYCUSTID"]) + "\" }," +
|
"\"FOwnerTypeIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOWNERTYPEID"]) + "\"," +
|
"\"FOwnerIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOWNERID"]) + "\" }," +
|
//"FScanBox": "",
|
//"FCDateOffsetUnit": "",
|
//"FCDateOffsetValue": 0,
|
"\"FIsTotalServiceOrCost\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsTotalServiceOrCost"]) + "," +
|
//"FSHOPNUMBER": "",
|
//"FGYDATE": "1900-01-01",
|
"\"FBUSINESSTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBUSINESSTYPE"]) + "\"," +
|
"\"FRECCONTACTID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRECCONTACTID"]) + "\" }," +
|
"\"SubHeadEntity\":{ \"FSETTLECURRID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLECURRID"]) + "\" }," +
|
//"FThirdBillNo": "",
|
//"FThirdBillId": "",
|
//"FThirdSrcType": "",
|
"\"FSETTLEORGID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLEORGID"]) + "\" }," +
|
"\"FSETTLETYPEID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLETYPEID"]) + "\" }," +
|
//"FChageCondition": {"FNumber": ""},
|
//"FPriceListId": {"FNumber": ""},
|
//"FDiscountListId": {"FNumber": ""},
|
"\"FLOCALCURRID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FLOCALCURRID"]) + "\" }," +
|
"\"FEXCHANGETYPEID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FEXCHANGETYPEID"]) + "\" }," +
|
"\"FExchangeRate\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FExchangeRate"]) + "," +
|
//"FBuyerNick": "",
|
//"FReceiverAddress": "",
|
//"FReceiverName": "",
|
//"FReceiverMobile": "",
|
//"FReceiverCountry": "",
|
//"FReceiverState": "",
|
//"FReceiverCity": "",
|
//"FReceiverDistrict": "",
|
//"FReceiverPhone": ""
|
"\"FRECEIPTCONDITIONID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FRECEIPTCONDITIONID"]) + "\" }," +
|
"\"FISINCLUDEDTAX\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISINCLUDEDTAX"]) + "," +
|
"\"FISPRICEEXCLUDETAX\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISPRICEEXCLUDETAX"]) + "}," +
|
"\"FEntity\": [ ";
|
string sJson_Entry = "";
|
for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
|
{
|
if (sJson_Entry != "")
|
{
|
sJson_Entry = sJson_Entry + " , ";
|
}
|
string sJson_BatchNo = "";
|
string sJson_StockPlace = "";
|
string sJson_FDELIVERYDATE = "";
|
string sJson_FPRODUCEDATE = "";
|
string sJson_FEXPIRYDATE = "";
|
string sJson_FVAT = "";
|
string sJson_FSELLERWITHHOLDING = "";
|
string sJson_FBUYERWITHHOLDING = "";
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1") //是否启用批次管理
|
{
|
sJson_BatchNo = " \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"}, \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\" , ";
|
}
|
else
|
{
|
sJson_BatchNo = "";
|
}
|
|
if (oSystemParameterMain.WMS_CampanyName == "卓力") //系统参数 客户定制化名称 空白为通用 仓位
|
{
|
sJson_StockPlace = "\"FStockLocId\":{\"FSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) + "\"}},";
|
}
|
else
|
{
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) == "")
|
{
|
sJson_StockPlace = "";
|
}
|
else
|
{
|
sJson_StockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) + "\"}},";
|
}
|
}
|
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDELIVERYDATE"]) == "")//退货日期
|
{
|
sJson_FDELIVERYDATE = "";
|
}
|
else
|
{
|
sJson_FDELIVERYDATE = "\"FDELIVERYDATE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDELIVERYDATE"]) + "\",";
|
}
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCEDATE"]) == "")//生产日期
|
{
|
sJson_FPRODUCEDATE = "";
|
}
|
else
|
{
|
sJson_FPRODUCEDATE = "\"FPRODUCEDATE\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRODUCEDATE"]) + "\" },";
|
}
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXPIRYDATE"]) == "")//有效期至
|
{
|
sJson_FEXPIRYDATE = "";
|
}
|
else
|
{
|
sJson_FEXPIRYDATE = "\"FEXPIRYDATE\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXPIRYDATE"]) + "\" },";
|
}
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FVAT"]) == "")//增值税
|
{
|
sJson_FVAT = "";
|
}
|
else
|
{
|
sJson_FVAT = ",\"FVAT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FVAT"]) + "";
|
}
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSELLERWITHHOLDING"]) == "")//卖方代扣代缴
|
{
|
sJson_FSELLERWITHHOLDING = "";
|
}
|
else
|
{
|
sJson_FSELLERWITHHOLDING = ",\"FSELLERWITHHOLDING\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSELLERWITHHOLDING"]) + "";
|
}
|
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBUYERWITHHOLDING"]) == "")//买方代扣代缴
|
{
|
sJson_FBUYERWITHHOLDING = "";
|
}
|
else
|
{
|
sJson_FBUYERWITHHOLDING = ",\"FBUYERWITHHOLDING\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBUYERWITHHOLDING"]) + "";
|
}
|
|
sJson_Entry = sJson_Entry + "{\"FEntryID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntryID"]) + "\"," +
|
"\"FROWTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FROWTYPE"]) + "\"," +
|
"\"FMAPID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMAPID"]) + "\" }," +
|
"\"FMATERIALID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMATERIALID"]) + "\" }," +
|
//"\"FAUXPROPID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXPROPID"]) + "," +
|
"\"FUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUNITID"]) + "\" }," +
|
//"FInventoryQty": 0,
|
"\"FRealQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRealQty"]) + "," +
|
"\"FPARENTMATID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPARENTMATID"]) + "\" }," +
|
"\"FPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICE"]) + "," +
|
"\"FTAXPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXPRICE"]) + "," +
|
"\"FISFREE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "," +
|
"\"FTAXCOMBINATION\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXCOMBINATION"]) + "\" }," +
|
"\"FEntryTaxRate\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntryTaxRate"]) + "," +
|
"\"FBOMID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMID"]) + "\" }," +
|
"\"FRETURNTYPE\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRETURNTYPE"]) + "\" }," +
|
"\"FOWNERTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERTYPEID"]) + "\"," +
|
"\"FOWNERID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOWNERID"]) + "\" }," +
|
sJson_FPRODUCEDATE +
|
sJson_FEXPIRYDATE +
|
"\"FSTOCKID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKID"]) + "\" }," +
|
sJson_StockPlace +
|
"\"FStockStatusID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockStatusID"]) + "\" }," +
|
"\"FSRCBILLTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPEID"]) + "\"," +
|
sJson_FDELIVERYDATE +
|
"\"FMTONO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMTONO"]) + "\"," +
|
"\"FNOTE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FNOTE"]) + "\"," +
|
"\"FDISCOUNTRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDISCOUNTRATE"]) + "," +
|
//"FPriceDiscount": 0,
|
//"FAuxUnitQty": 0,
|
"\"FEXTAUXUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEXTAUXUNITID"]) + "\" }," +
|
//"FExtAuxUnitQty": 0,
|
//"FSalCostPrice": 0,
|
//"FISCONSUMESUM": "",
|
"\"FBaseunitQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseunitQty"]) + "," + //没按次序添加
|
"\"FBASEUNITQTYOLD\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITQTYOLD"]) + "," + //没按次序添加
|
sJson_BatchNo +
|
"\"FSALUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALUNITID"]) + "\" }," +
|
"\"FSALUNITQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALUNITQTY"]) + "," +
|
"\"FSALBASEQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALBASEQTY"]) + "," +
|
"\"FPRICEBASEQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICEBASEQTY"]) + "," +
|
//"FProjectNo": "",
|
//"FQualifyType": "",
|
//"FEOwnerSupplierId": {"FNUMBER": ""},
|
"\"FIsOverLegalOrg\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsOverLegalOrg"]) + "," +
|
//"FESettleCustomerId": {"FNUMBER": ""},
|
"\"FSOENTRYID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSOENTRYID"]) + "," +
|
//"FThirdEntryId": "",
|
//"FPriceListEntry": {"FNUMBER": ""},
|
"\"FARNOTJOINQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FARNOTJOINQTY"]) + "," +
|
"\"FIsReturnCheck\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsReturnCheck"]) + "," +
|
//"FETHIRDBILLID": "",
|
//"FETHIRDBILLNO": "",
|
//"F_fp": "",
|
"\"FSOBILLTYPEID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSOBILLTYPEID"]) + "\" }," +
|
"\"FKEEPERID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKEEPERID"]) + "\" }," +
|
"\"FBASEUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITID"]) + "\" }," +
|
"\"FAUXUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAUXUNITID"]) + "\" }," +
|
"\"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
|
"\"FORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERNO"]) + "\"," +
|
"\"FPRICEUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICEUNITID"]) + "\" }," +
|
"\"FPRICECOEFFICIENT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPRICECOEFFICIENT"]) + "," +
|
"\"FSYSPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSYSPRICE"]) + "," +
|
"\"FLIMITDOWNPRICE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLIMITDOWNPRICE"]) + "," +
|
"\"FSNUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSNUNITID"]) + "\" }," +
|
"\"FSRCBIZUNITID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBIZUNITID"]) + "\" }," +
|
//"\"FROWID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FROWID"]) + "\" }," +
|
//"\"FPARENTROWID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPARENTROWID"]) + "\" }," +
|
"\"FMustQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMustQty"]) + "," +
|
"\"FOUTCONTROL\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOUTCONTROL"]) + "," +
|
"\"FSALBASENUM\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSALBASENUM"]) + "," +
|
"\"FSTOCKBASEDEN\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKBASEDEN"]) + "," +
|
"\"FTaxDetailSubEntity\": [ { " +
|
//"FDetailID": 0,
|
"\"FTAXRATE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXRATE"]) + "," +
|
"\"FTAXRATEID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXRATEID"]) + "\" }," +
|
"\"FTAXAMOUNT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTAXAMOUNT"]) + "," +
|
"\"FCOSTPERCENT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTPERCENT"]) + "," +
|
"\"FCOSTAMOUNT\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCOSTAMOUNT"]) + "" +
|
sJson_FVAT +
|
sJson_FSELLERWITHHOLDING +
|
sJson_FBUYERWITHHOLDING +
|
" } ]," +
|
//"\"FSerialSubEntity\": [ { " +
|
// "FDetailID": 0,
|
// "FSerialNo": "",
|
// "FSerialNote": ""
|
//" } ]," +
|
"\"FEntity_Link\": [ { " +
|
"\"FEntity_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FRuleId"]) + "\"," +
|
"\"FEntity_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSTableName"]) + "\"," +
|
"\"FEntity_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSBillId"]) + "\"," +
|
"\"FEntity_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntity_Link_FSId"]) + "\"" +
|
" } ] } ";
|
}
|
string sJson_End = " ] }}";
|
string sJson = sJson_Main + sJson_Entry + sJson_End;
|
|
//从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
|
if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
|
{
|
sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
|
return false;
|
}
|
|
//生成 销售退货单
|
string HReturn;
|
ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
|
string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
|
bool bLogin = client.Login(dbId, Pub_Class.ClsPub.sCLOUDUseName, Pub_Class.ClsPub.sCLOUDPsd, 2052);
|
if (bLogin)
|
{
|
var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
|
new object[] { "SAL_RETURNSTOCK", sJson });
|
|
if (oSystemParameterMain.Kf_SellOutBackBill_AutoCheck == "Y") //系统参数 自动审核
|
{
|
string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
|
var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
|
new object[] { "SAL_RETURNSTOCK", sJson2 });
|
|
string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
|
var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
|
new object[] { "SAL_RETURNSTOCK", sJson3 });
|
|
HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
|
}
|
else
|
{
|
HReturn = result.ToString();
|
}
|
if (HReturn.Contains("\"IsSuccess\":false") == true)
|
{
|
sErrMsg = "生成销售退货单失败!" + HReturn + sJson;
|
oCn.RollBack();
|
return false;
|
}
|
else
|
{
|
sErrMsg = "999999" + HReturn + sJson;
|
oCn.Commit();
|
return true;
|
}
|
}
|
else
|
{
|
sErrMsg = "生成销售退货单失败!登录失败!";
|
oCn.RollBack();
|
return false;
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
sErrMsg = "生成销售退货单失败!" + e.Message;
|
oCn.RollBack();
|
return false;
|
}
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
}
|
}
|