using System; using System.Collections.Generic; using System.Text; using System.Data; using Kingdee.BOS.WebApi.Client; namespace BLL { public class ClsKf_ProductInBackBill { /// /// 根据过滤条件,返回源单信息-产品入库单列表(蓝字)(红字产品入库源单) /// /// 过滤条件 /// 错误信息 /// public DataSet GetKf_ProductInBillList(string sWhere, ref string sErr) { try { DAL.Cls_S_IF_ProductInBill_Lite dal = new DAL.Cls_S_IF_ProductInBill_Lite(); return dal.DisSourceBillList(sWhere); } catch (Exception e) { sErr = sErr + "," + e.Message; return null; } } /// /// 根据过滤条件,返回源单信息-生产任务单列表 退库(红字产品入库源单) /// /// 过滤条件 /// 错误信息 /// public DataSet GetSc_ICMOBackBillList(string sWhere, ref string sErr) { try { DAL.Cls_S_IF_ICMOBackBill_Lite dal = new DAL.Cls_S_IF_ICMOBackBill_Lite(); return dal.DisSourceBillList(sWhere); } catch (Exception e) { sErr = sErr + "," + e.Message; return null; } } //生成产品退库单 public bool set_SaveProductInBackBill_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_ProductInBackBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE { if (SaveProductInBackBill_K3(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg)) { //"保存成功!"; sErrMsg = "保存成功!" + oMain.HBillNo; return true; } else { //"保存失败!"; sErrMsg = sErrMsg; return false; } } if (oSystemParameter.omodel.Kf_ProductInBackBill_ERPMode.ToUpper() == "CLOUD") //判断同步模式是金蝶CLOUD { } sErrMsg = "保存产品退库单失败!" + sErrMsg; return false; } #region 产品退库K3 产品入库(红字) * /// /// 生成产品退库单K3 /// /// /// /// public bool SaveProductInBackBill_K3(Model.ClsKf_ICStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DAL.ClsKf_ProductInBackBill dal = new DAL.ClsKf_ProductInBackBill(); dal.omodel = oMain; //上传前必填项判断 if (oMain.HDeptID == 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_ProductInBackBillSub_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('1245','1245'," + 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_ProductInBackBill_Insert_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'," + oMain.HBillerID.ToString() + ",'" + sHSourceType + "'"); //更新关联数量 if (sHSourceType == "3710") //生产任务单-退库 { oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToProductInBack_Add " + oMain.HInterID.ToString()); //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_ProductInBackBill_UpdateBillRelateData_ICMO " + oMain.HInterID.ToString()); } else if (sHSourceType == "1202") //产品入库单-蓝字 { oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToProductInBack_Add " + oMain.HInterID.ToString()); //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_ProductInBackBill_UpdateBillRelateData_Blue " + oMain.HInterID.ToString()); } else //无源单 { //回填K3关联数量 oCn.RunProc("exec h_p_IFK3_ToERP_ProductInBackBill_UpdateBillRelateData " + oMain.HInterID.ToString()); } //审核单据 if (oSystemParameterMain.Kf_ProductInBackBill_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_ProductInBackBill_Check " + oMain.HInterID.ToString() + "," + oMain.HBillerID.ToString()); //更新K3库存 oCn.RunProc("exec h_p_IFK3_ToERP_ProductInBackBill_UpdateStock " + oMain.HInterID.ToString()); oCn.RunProc("exec h_p_IFK3_ToERP_ProductInBackBill_UpdateOrderStock " + oMain.HInterID.ToString()); } //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 } }