using System; using System.Collections.Generic; using System.Text; using System.Data; using Kingdee.BOS.WebApi.Client; namespace BLL { public class ClsKf_EntrustOutBackBill { /// /// 根据过滤条件,返回源单信息-返回委外出库单-蓝字列表 (红字委外出库源单) /// /// 过滤条件 /// 错误信息 /// public DataSet GetKf_EntrustOutBillList(string sWhere, ref string sErr) { try { DAL.Cls_S_IF_EntrustOutBill_Lite dal = new DAL.Cls_S_IF_EntrustOutBill_Lite(); return dal.DisSourceBillList(sWhere); } catch (Exception e) { sErr = sErr + "," + e.Message; return null; } } /// /// 根据过滤条件,返回源单信息-返回委外订单投料单-退料列表 退料(红字委外出库源单) /// /// 过滤条件 /// 错误信息 /// public DataSet GetWW_WWPPBomBackList(string sWhere, ref string sErr) { try { DAL.Cls_S_IF_WWPPBomBackBill_Lite dal = new DAL.Cls_S_IF_WWPPBomBackBill_Lite(); return dal.DisSourceBillList(sWhere); } catch (Exception e) { sErr = sErr + "," + e.Message; return null; } } //生成委外退料单 public bool set_SaveEntrustOutBackBill_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_EntrustOutBackBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE { if (SaveEntrustOutBackBill_K3(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg)) { //"保存成功!"; sErrMsg = "保存成功!" + oMain.HBillNo; return true; } else { //"保存失败!"; sErrMsg = sErrMsg; return false; } } if (oSystemParameter.omodel.Kf_EntrustOutBackBill_ERPMode.ToUpper() == "CLOUD") //判断同步模式是金蝶CLOUD { } sErrMsg = "保存委外退料单失败!" + sErrMsg; return false; } #region 委外退料CLOUD * //生成外购入库单 public bool set_SaveEntrustInBackBill_CLD(Model.ClsKf_EntrustInBackBillMain_CLD oMain, string sHSourceType, ref string sErrMsg) { if (SaveEntrustInBackBill_CLD(oMain, ref sErrMsg)) { //"保存成功!"; sErrMsg = "保存成功!" + oMain.HBillNo; return true; } else { //"保存失败!"; sErrMsg = sErrMsg; return false; } } //委外退料 private bool SaveEntrustInBackBill_CLD(Model.ClsKf_EntrustInBackBillMain_CLD oMain, ref string sErrMsg) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); try { DataSet Ds; //根据TMP表 返回 子表信息 Ds = oCn.RunProcReturn("exec h_p_Kf_GetEntrustInBackBill_CLD " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetEntrustInBackBill_CLD"); if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0) { sErrMsg = "获取子表信息失败!"; return false; } else { //string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\": { \"FID\":\"0\", \"FBILLNO\":\"" + oMain.HBillNo + "\", \"FStockOrgId\":{\"FNumber\":\"201\"}, " + // "\"FPRDORGID\":{\"FNumber\":\"201\"}, \"FBillType\": {\"FNumber\":\"SCLLD01_SYS\" " + // " }, \"FEntity\": [ "; string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\", " + "\"IsEntryBatchFill\":\"True\",\"Model\":{\"FID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FID"]) + "\"," + "\"FBillTypeID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\"}," + "\"FBillNo\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillNo"]) + "\"," + "\"FDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDate"]) + "\", " + "\"FMRTYPE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRTYPE"]) + "\", " + "\"FMRMODE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRMODE"]) + "\", " + "\"FMRDeptId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRDeptId"]) + "\"}," + "\"FStockOrgId\":{\"FNumber\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\"}," + "\"FStockDeptId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockDeptId"]) + "\"}," + "\"FRequireOrgId\":{\"FNumber\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\"}," + "\"FDESCRIPTION\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDESCRIPTION"]) + "\"}," + "\"FACCEPTORID\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FACCEPTORID"]) + "\"}," + "\"FStockerGroupId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockerGroupId"]) + "\"}," + "\"FStockerId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockerId"]) + "\"}, " + "\"FMRREASON\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FMRREASON"]) + "\"}, " + "\"FAcceptAddress\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FAcceptAddress"]) + "\"}, " + "\"FDemandOrgId\":{\"FNumber\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\"}," + "\"FCorrespondOrgId\":{\"FNumber\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\"}," + "\"FPurchaseOrgId\":{\"FNumber\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\"}," + "\"FPurchaseDeptId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPurchaseDeptId"]) + "\"}, " + "\"FPurchaserGroupId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPurchaserGroupId"]) + "\"}," + "\"FPurchaserId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPurchaserId"]) + "\"}," + "\"FSupplierId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplierId"]) + "\"}," + "\"FSupplyId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyId"]) + "\"}, " + "\"FSupplyAddress\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSupplyAddress"]) + "\"," + "\"FSettleId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleId"]) + "\"}," + "\"FChargeId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FChargeId"]) + "\"}," + "\"FOwnerTypeIdHead\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\", " + "\"FOwnerIdHead\":{\"FNumber\":\"" + oMain.HORGANIZATIONSNO.ToString() + "\"}," + "\"FScanPoint\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FScanPoint"]) + "\"}," + "\"FConfirmerId\":{\"FUserID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FConfirmerId"]) + "\"}," + "\"FConfirmDate\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FConfirmDate"]) + "\"," + "\"FScanBox\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FScanBox"]) + "\"," + "\"FCDateOffsetUnit\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCDateOffsetUnit"]) + "\", " + "\"FCDateOffsetValue\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FCDateOffsetValue"]) + "," + "\"FPURMRBFIN FSettleOrgId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPURMRBFIN FSettleOrgId"]) + "," + "\"FAcceptorContactID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FAcceptorContactID"]) + "," + "\"FProviderContactID\":{\"FCONTACTNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FProviderContactID"]) + "\"}," + "\"FInStockFin\":{\"FSettleOrgId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleOrgId"]) + "\"}," + "\"FSettleTypeId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleTypeId"]) + "\"}, " + "\"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"]) + "\"," + "\"FPriceListId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FPriceListId"]) + "\"}," + "\"FDiscountListId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDiscountListId"]) + "\"}," + "\"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"]) + "" + " }, \"FPURMRBENTRY\": [ "; string sJson_Entry = ""; for (int i = 0; i < Ds.Tables[1].Rows.Count; i++) { if (sJson_Entry != "") { sJson_Entry = sJson_Entry + " , "; } 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"]) + "\"}, " + "\"FMaterialDesc\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialDesc"]) + "\"}, " + "\"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"]) + "\"}," + "\"FLot\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLot"]) + "\"}," + "\"FStockId\":{\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockId"]) + "\"}," + "\"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"]) + "\"," + "\"FORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERNO"]) + "\"," + "\"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]["FEntryID"]) + "," + "\"FNote\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FGiveAway"]) + "," + "\"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]["FSetPriceUnitID"]) + "," + "\"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"]) + "," + "\"FBASEREPLAYQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBASEREPLAYQTY"]) + "," + "\"FREPLENISHQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREPLENISHQTY"]) + "," + "\"FKEAPAMTQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKEAPAMTQTY"]) + "," + "\"FSTOCKID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSTOCKID"]) + "," + "\"FStockStatusId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FStockStatusId"]) + "," + "\"FREQTRACENO\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FREQTRACENO"]) + "," + "\"FChargeProjectID\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FChargeProjectID"]) + "," + "\"FCarryUnitId\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCarryUnitId"]) + "," + "\"FCarryQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCarryQty"]) + "," + "\"FCarryBaseQty\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCarryBaseQty"]) + "," + "\"FPriceListEntry\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceListEntry"]) + "," + "\"FRMMUSTQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRMMUSTQTY"]) + "," + "\"FRMREALQTY\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FRMREALQTY"]) + "," + "\"FIsStock\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FIsStock"]) + "," + "\"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_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FInStockEntry_Link_FRuleId"]) + "\" , " + "\"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单 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[] { "SUB_RETURNMTRL", sJson }); string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}"; var result2 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit", new object[] { "SUB_RETURNMTRL", sJson2 }); string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}"; var result3 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit", new object[] { "SUB_RETURNMTRL", sJson3 }); string HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString(); if (HReturn.Contains("\"IsSuccess\":false") == true) { sErrMsg = "生成采购退料单失败!" + HReturn; return false; } else { return true; } } else { sErrMsg = "生成采购入退料失败!登录失败!"; return false; } } } catch (Exception e) { sErrMsg = "生成采购入退料失败!" + e.Message; return false; } } #endregion #region 委外退料K3 委外出库(红字) * /// /// 生成委外退料单K3 /// /// /// /// public bool SaveEntrustOutBackBill_K3(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DAL.ClsKf_EntrustOutBackBill dal = new DAL.ClsKf_EntrustOutBackBill(); 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_EntrustOutBackBillSub_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('1238','1238'," + 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_EntrustOutBackBill_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'," + oMain.HBillerID.ToString() + ",'" + sHSourceType + "'"); //更新关联数量 if (sHSourceType == "3720") //委外订单-退料 { oCn.RunProc("exec h_p_WW_UpDateRelation_WWPPBomToEntrustOutBack_Add " + oMain.HInterID.ToString()); //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustOutBackBill_UpdateBillRelateData_EntrustOrder " + oMain.HInterID.ToString()); } else if (sHSourceType == "1211") //委外出库单-蓝字 { oCn.RunProc("exec h_p_Kf_UpDateRelation_EntrustOutToEntrustOutBack_Add " + oMain.HInterID.ToString()); //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustOutBackBill_UpdateBillRelateData_Blue " + oMain.HInterID.ToString()); } else //无源单 { //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustOutBackBill_UpdateBillRelateData " + oMain.HInterID.ToString()); } //审核单据 if (oSystemParameterMain.Kf_EntrustOutBackBill_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_EntrustOutBackBill_Check " + oMain.HInterID.ToString() + "," + oMain.HBillerID.ToString()); //更新K3库存 oCn.RunProc("exec h_p_IFK3_ToERP_EntrustOutBackBill_UpdateStock " + oMain.HInterID.ToString()); oCn.RunProc("exec h_p_IFK3_ToERP_EntrustOutBackBill_UpdateOrderStock " + oMain.HInterID.ToString()); } sErrMsg = "新增单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sErrMsg = "生成委外退料单失败!" + e.Message; oCn.RollBack(); return false; } } #endregion } }