using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsKf_CheckStockInBill_K3 : DBUtility.ClsXt_BaseBill { public Model.ClsKf_CheckStockBillMain_K3 omodel = new Model.ClsKf_CheckStockBillMain_K3(); public List DetailColl = new List(); public SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3(); public ClsKf_CheckStockInBill_K3() { base.MvarItemKeySub = "ICStockBillEntry"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey = "ICStockBill"; base.MvarReportTitle = "盘盈入库"; base.BillType = "40"; } #region 固定代码 ~ClsKf_CheckStockInBill_K3() { DetailColl = null; } #endregion 自定义方法 //单据号是否重复 public virtual bool IsExistBillNo(ref string sReturn, string sBillNo, DBUtility.ClsPub.Enum_BillStatus oBillStatus, Int64 lngBillKey) { try { string sSql = ""; if (oBillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew) { sSql = "Select FInterID from ICStockBill where FTranType='" + MvarItemKey + "' and FBillNo ='" + sBillNo + "'"; } else { sSql = "Select FInterID from ICStockBill where FTranType='" + MvarItemKey + "' and FBillNo ='" + sBillNo + "' and FInterID<>" + lngBillKey.ToString(); } DataSet Ds; Ds = oCnK3.RunProcReturn(sSql, "ICStockBill"); if (Ds.Tables[0].Rows.Count != 0) { sReturn = "单号重复"; return true; } sReturn = "单号未重复"; return false; } catch (Exception e) { sReturn = e.Message; return false; } } //删除单据 public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn) { try { DataSet Ds; oCnK3.BeginTran(); // Ds = oCnK3.RunProcReturn("select FSourceInterID from ICStockBillEntry where finterid=" + lngBillKey, "ICStockBillEntry"); //删除关联 //删除明细表 oCnK3.RunProc("Delete From ICStockBillEntry where FInterID=" + lngBillKey.ToString()); //删除主表 oCnK3.RunProc("Delete From icstockbill where FInterID=" + lngBillKey.ToString()); //删除关联 sReturn = "删除单据成功!"; oCnK3.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCnK3.RollBack(); throw (e); } } //删除关联 public override void DeleteRelation(ref string sReturn, Int64 lngBillKey) { //oCn.RunProc("exec h_p_K3_MateOutRequestRelationQtyBack " + lngBillKey + ",'376001'"); //sReturn = ""; return; } //条码扫描记录,新增到盘盈入库 public bool AddBill_PDA(string sHMaker, ref string sReturn) { try { DataSet Ds; DataSet Ds1; long sNewInterID = 0; string sNewBillNo = ""; oCnK3.BeginTran(); Ds1 = oCnK3.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNumOld 'ICStockBill',@InterID output select ltrim(@InterID)", "xt_xtgnb"); if (Ds1.Tables[0].Rows.Count != 0) { sNewInterID = DBUtility.ClsPub.isLong(Ds1.Tables[0].Rows[0][0]); } sNewBillNo = DBUtility.Xt_BaseBillFun.get_MaxBillNo_K3(this.BillType, oCnK3); //删除主表 //oCnK3.RunProc("Delete From ICStockBill where FInterID=" + sNewInterID.ToString()); //插入子表 oCnK3.RunProc("EXEC h_p_Kf_CheckStockInBillSub_Insert_K3 " + omodel.HInterID.ToString() + "," + sNewInterID.ToString() + ",'" + sHMaker + "'"); //插入主表 oCnK3.RunProc("INSERT INTO ICStockBill" + "(FInterID,FBillNo,FBrNo,FTranType,FCancellation" + ",FStatus,FUpStockWhenSave,FHookStatus,Fdate" + ",FCheckDate,FFManagerID,FBillerID" + ",FMultiCheckDate1,FMultiCheckDate2,FMultiCheckDate3" + ",FMultiCheckDate4,FMultiCheckDate5,FMultiCheckDate6" + ",FBrID,FManagerID,FEmpID,FProcID" + ",FVchInterID,FPrintCount,FInventoryType) " + "VALUES " + "(" + sNewInterID.ToString() + ",'" + sNewBillNo + "','0'," + this.BillType + ",0" + ",0,0,0,convert(varchar(10),getdate(),120)" + ",Null," + omodel.HFManagerID + "," + omodel.HBillerID + "" + ",Null,Null,Null" + ",Null,Null,Null" + ",0,0,0,0" + ",0,0,36700" + ") "); //更新K3关联数量 //oCnK3.RunProc("EXEC p_UpdateBillRelateData " + this.BillType + "," + omodel.HInterID.ToString() + ",'ICStockBill','ICStockBillEntry'"); //oCnK3.RunProc("EXEC h_p_K3_UpdateBillRelateData_ProdIn_New " + omodel.HInterID.ToString()); //更新单据NEWid oCnK3.RunProc("UPDATE ICStockBill SET FUUID=NEWID() WHERE FInterID=" + sNewInterID.ToString()); //审核单据 oCnK3.RunProc("EXEC h_p_Kf_CheckStockInBill_Check_K3 " + sNewInterID.ToString() + "," + omodel.HBillerID.ToString()); sReturn = "新增单据成功!"; oCnK3.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCnK3.RollBack(); throw (e); } } //条码扫描记录,新增到条码出入库表(K3无需生成盘点单) public bool AddBill_WMS_PDA(Int64 HInterID, Int64 HWHID, Int64 HSPID,string sHMaker, ref string sReturn) { try { DataSet Ds; oCn.BeginTran(); //新增条码盘盈单 oCn.RunProc("EXEC h_p_Kf_ICStockBillSub_WMS_Insert_CheckStockIn " + HInterID + ",'" + sHMaker + "'"); //新增条码盘亏单 oCn.RunProc("EXEC h_p_Kf_ICStockBillSub_WMS_Insert_CheckStockOut " + HInterID + "," + HWHID + "," + HSPID + ",'" + sHMaker + "'"); // sReturn = "新增单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } } }