using System; using System.Collections.Generic; using System.Text; using System.Data; using Kingdee.BOS.WebApi.Client; namespace BLL { public class ClsKf_EntrustInBill { /// /// 根据过滤条件,返回源单信息-返回委外订单列表 /// /// 过滤条件 /// 错误信息 /// public DataSet GetWW_WWOrderBillList(string sWhere, ref string sErr) { try { DAL.Cls_S_IF_WWOrderBill_Lite dal = new DAL.Cls_S_IF_WWOrderBill_Lite(); return dal.DisSourceBillList(sWhere); } catch (Exception e) { sErr = sErr + "," + e.Message; return null; } } //生成委外入库单 public bool set_SaveEntrustInBill_New(Model.ClsKf_EntrustInBillMain 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_EntrustInBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE { if (SaveEntrustInBill_K3(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg)) { //"保存成功!"; sErrMsg = "保存成功!" + oMain.HBillNo; return true; } else { //"保存失败!"; sErrMsg = sErrMsg; return false; } } if (oSystemParameter.omodel.Kf_EntrustInBill_ERPMode.ToUpper() == "CLOUD") //判断同步模式是金蝶CLOUD { if (set_SaveEntrustInBill_CLD(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg) == true) { //"保存成功!"; return true; } else { //"保存失败!"; return false; } } sErrMsg = "保存委外入库单失败!" + sErrMsg; return false; } #region 委外入库K3 * /// /// 生成委外入库单K3 /// /// /// /// public bool SaveEntrustInBill_K3(Model.ClsKf_EntrustInBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DAL.ClsKf_EntrustInBill dal = new DAL.ClsKf_EntrustInBill(); dal.omodel = oMain; //上传前必填项判断 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_EntrustInBillSub_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('1210','1210'," + 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.HMangerID.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_EntrustInBill_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'," + oMain.HBillerID.ToString() + ",'" + sHSourceType + "'"); //更新关联数量 if (sHSourceType == "1601") //委外订单 { oCn.RunProc("exec h_p_WW_UpDateRelation_EntrustOrderToEntrustIn_Add " + oMain.HInterID.ToString()); //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustInBill_UpdateBillRelateData_EntrustOrder_New " + oMain.HInterID.ToString()); } else if (sHSourceType == "1103") //收料通知单 { oCn.RunProc("exec h_p_Cg_UpDateRelation_POInStockToEntrustIn_Add " + oMain.HInterID.ToString()); //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustInBill_UpdateBillRelateData_POInStock_New " + oMain.HInterID.ToString()); } else //无源单 { //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustInBill_UpdateBillRelateData_New " + oMain.HInterID.ToString()); } //审核单据 if (oSystemParameterMain.Kf_EntrustInBill_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_EntrustInBill_Check_New " + oMain.HInterID.ToString() + "," + oMain.HBillerID.ToString()); //更新K3库存 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustInBill_UpdateStock_New " + oMain.HInterID.ToString()); oCn.RunProc("exec h_p_IFK3_ToERP_EntrustInBill_UpdateOrderStock_New " + oMain.HInterID.ToString()); } sErrMsg = "新增单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sErrMsg = "生成委外入库单失败!" + e.Message; oCn.RollBack(); return false; } } #endregion #region 委外入库CLOUD //生成外购入库单 public bool set_SaveEntrustInBill_CLD(Model.ClsKf_EntrustInBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg) { if (sHSourceType == "1103") //收料通知单 { if (SaveEntrustInBill_CLD(oMain, oSystemParameterMain, ref sErrMsg)) { //"保存成功!"; sErrMsg = "保存成功!" + oMain.HBillNo; return true; } else { //"保存失败!"; sErrMsg = sErrMsg; return false; } } else { sErrMsg = "错误的源单类型"; return false; } } /// /// 委外入库 /// /// /// /// public bool SaveEntrustInBill_CLD(Model.ClsKf_EntrustInBillMain oMain, 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_EntrustInBillSub_Insert " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'"); //插入主表 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('1210','1210'," + 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.HMangerID.ToString() + "," + oMain.HSecManagerID.ToString() + ", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) + ") "); //更新关联数量 oCn.RunProc("exec h_p_Cg_UpDatePOInStockRelation_Add " + oMain.HInterID.ToString()); if (oSystemParameterMain.Kf_EntrustInBill_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_GetEntrustInBill_CLD " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetEntrustInBill_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\",\"Model\":{"+ //\"FID\":\"" + oMain.HInterID.ToString() + "\"," + "\"FBillTypeID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\"}," + "\"FBUSINESSTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBUSINESSTYPE"]) + "\"," + "\"FBillNo\":\"" + oMain.HBillNo + "\"," + // "\"FDate\":\"" + oMain.HDate.ToShortDateString() + "\"," + "\"FStockOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," + "\"FStockDeptId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockDeptId"]) + "\"}," + "\"FStockerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockerId"]) + "\"}," + "\"FDemandOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," + "\"FPurchaseOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," + "\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}," + "\"FSupplyId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}," + "\"FSettleId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}," + "\"FChargeId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}," + "\"FOwnerTypeIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeIdHead"]) + "\", " + "\"FOwnerIdHead\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerIdHead"]) + "\"}," + "\"FCDateOffsetValue\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCDateOffsetValue"]) + "," + "\"FInStockFin\":{\"FSettleOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\"}," + "\"FPayConditionId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPayConditionId"]) + "\"}," + "\"FSettleCurrId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleCurrId"]) + "\"}," + "\"FIsIncludedTax\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsIncludedTax"]) + "," + "\"FPriceTimePoint\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPriceTimePoint"]) + "," + "\"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"]) + ", " + //"\"FISPRICEEXCLUDETAX\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FISPRICEEXCLUDETAX"]) + " " + " }, \"FInStockEntry\": [ "; 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 = ""; 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 (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"]) + "\"}},"; } 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"]) + "\"," + "\"FWWInType\":\" " + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FWWInType"]) + "\"," + "\"FMaterialId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialId"]) + "\"}," + "\"FUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\"}," + "\"FParentMatId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FParentMatId"]) + "\"}," + "\"FRealQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRealQty"]) + "," + "\"FPriceUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceUnitID"]) + "\"}," + "\"FPrice\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPrice"]) + ", " + "\"FTaxCombination\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTaxCombination"]) + "\"}," + sJson_BatchNo+ "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," + sJson_StockPlace + //"\"FStockLocId\":{\"FSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockLocId"]) + "\"}}," + //"\"FDisPriceQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDisPriceQty"]) + ", " + "\"FSRCBILLTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPEID"]) + "\"," + "\"FRECEIVESTOCKSTATUS\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRECEIVESTOCKSTATUS"]) + "\"}," + "\"fpoorderentryid\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["fpoorderentryid"]) + ", " + "\"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," + "\"FPOORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPOORDERNO"]) + "\"," + "\"FStockStatusId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockStatusId"]) + "\"}," + //"\"FMtoNo\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMtoNo"]) + "," + "\"FGiveAway\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FGiveAway"]) + "," + "\"FNote\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FNote"]) + "\"," + //"\"FProduceDate\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProduceDate"]) + ", " + "\"FExtAuxUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExtAuxUnitId"]) + "\"}," + //"\"FExtAuxUnitQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExtAuxUnitQty"]) + "," + "\"FCheckInComing\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCheckInComing"]) + "," + //"\"FProjectNo\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FProjectNo"]) + "," + //"\"FSampleDamageQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSampleDamageQty"]) + "," + //"\"FSampleDamageBaseQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSampleDamageBaseQty"]) + ", " + "\"FIsReceiveUpdateStock\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsReceiveUpdateStock"]) + "," + //"\"FInvoicedJoinQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInvoicedJoinQty"]) + "," + //"\"FPriceBaseQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceBaseQty"]) + "," + "\"FSetPriceUnitID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSetPriceUnitID"]) + "\"}," + "\"FRemainInStockUnitId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRemainInStockUnitId"]) + "\"}, " + "\"FBILLINGCLOSE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBILLINGCLOSE"]) + "," + //"\"FRemainInStockQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRemainInStockQty"]) + "," + //"\"FAPNotJoinQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAPNotJoinQty"]) + "," + //"\"FRemainInStockBaseQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRemainInStockBaseQty"]) + "," + //"\"FBASEUNITQTYOLD\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEUNITQTYOLD"]) + "," + //"\"FREMAININSTOCKBASEQTYOLD\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREMAININSTOCKBASEQTYOLD"]) + "," + //"\"FTaxPrice\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTaxPrice"]) + "," + //"\"FEntryTaxRate\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FEntryTaxRate"]) + ", " + //"\"FDiscountRate\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDiscountRate"]) + "," + //"\"FCostPrice\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCostPrice"]) + "," + //"\"FBOMId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBOMId"]) + "\"}," + //"\"FSupplierLot\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSupplierLot"]) + "," + //"\"FExpiryDate\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FExpiryDate"]) + "," + //"\"FAuxUnitQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FAuxUnitQty"]) + "," + // "\"FBeforeDisPriceQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBeforeDisPriceQty"]) + ", " + "\"FInStockEntry_Link\": [ { " + "\"FInStockEntry_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInStockEntry_Link_FRuleId"]) + "\" , " + "\"FInStockEntry_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInStockEntry_Link_FSTableName"]) + "\" , " + "\"FInStockEntry_Link_FSBillId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInStockEntry_Link_FSBillId"]) + " , " + "\"FInStockEntry_Link_FSId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInStockEntry_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; } //生成委外入库单 1个物料1单 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("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save", new object[] { "STK_InStock", sJson }); if (oSystemParameterMain.Kf_EntrustInBill_AutoCheck == "Y") //系统参数 自动审核 { string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}"; var result2 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit", new object[] { "STK_InStock", sJson2 }); string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}"; var result3 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit", new object[] { "STK_InStock", 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 { oCn.Commit(); return true; } } else { sErrMsg = "生成委外入库单失败!登录失败!"; oCn.RollBack(); return false; } } } catch (Exception e) { sErrMsg = "生成委外入库单失败!" + e.Message; oCn.RollBack(); return false; } } #endregion } }