zrg
2024-01-16 b7f9458b0ec768c1bef45f83c1926031e2cc5cae
采购入库单收料通知单,保存前反写关联数量的存储过程
2个文件已修改
146 ■■■■ 已修改文件
WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs 88 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs
@@ -130,10 +130,11 @@
        /// <returns></returns>
        [Route("Cg_POInStockBill/DeltetPOInStockBill")]
        [HttpGet]
        public object DeltetPOInStockBill(string HInterID, string user)
        public object DeltetPOInStockBill(string HInterID, string HsupId, string HQty, string HSourceInterID, string HSourceEntryID, string user)
        {
            try
            {
                DataSet dss;
                //判断是否有删除的权限
                if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBill_Drop", 1, false, user))
                {
@@ -149,9 +150,31 @@
                if (objJsonResult.code == "0")
                    return objJsonResult;
                oCN.BeginTran();
                oCN.RunProc("Delete From Cg_POInStockBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Cg_POInStockBillSub where HInterID = " + HInterID);
                oCN.BeginTran(); //开始事务
                //查询数据
                ds = oCN.RunProcReturn("select * from Cg_POInStockBillMain a inner join Cg_POInStockBillSub b on a.HInterID=b.HInterID  where a.HInterID= '" + HInterID + "'", "Kf_ICStockBillMain");
               //执行存储过程进行反写
                dss = oCN.RunProcReturn("exec h_p_Cg_POOrderBillMain_Delete " + HQty + ", '" + HSourceInterID + "', '" + HSourceEntryID + "','" + user + " '", "h_p_Cg_POInStockBillMain");
                var sReturn = "";
                if (DBUtility.ClsPub.isLong(dss.Tables[0].Rows[0]["HBack"]) != 0)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(dss.Tables[0].Rows[0]["HBackRemark"]).ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = sReturn;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows.Count == 1)
                {
                    oCN.RunProc("delete Cg_POInStockBillMain where HInterID=" + HInterID);
                    oCN.RunProc("delete Cg_POInStockBillSub where HInterID=" + HInterID);
                }
                else
                {
                    oCN.RunProc($"delete Cg_POInStockBillSub where HInterID={ HInterID}and HEntryID={HsupId}");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -236,9 +259,9 @@
            }
        }
        //反审核 删除 删除金蝶数据库对应 收料通知到数据
        public json DeleteKingDee(string hinterid)
        public json DeleteKingDee(string HInterID)
        {
            string sql = string.Format("select HinterID,HERPBillNO,HERPInterID from Cg_POInStockBillMain where HERPInterID>0 and hinterid in (" + hinterid + ")");
            string sql = string.Format("select HinterID,HERPBillNO,HERPInterID from Cg_POInStockBillMain where HERPInterID>0 and hinterid in (" + HInterID + ")");
            DataTable dt = oCN.RunProcReturn(sql, "deleteDt").Tables[0];
            if (dt.Rows.Count > 0)
            {
@@ -408,13 +431,13 @@
                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" +
                                 ",HSupID=" + HSupID + ",HCurID=" + HCurID
                                 + ",HExRate=" + HExRate + ",HEmpID=" + HEmpID + ",HManagerID=" + HManagerID + ",HDeptID=" + HDeptID
                                 + ",HAddress='" + HAddress + " where HInterID=" + HInterID);
                                 + ",HAddress='" + HAddress + "' where HInterID=" + HInterID);
                    //删除子表
                    oCN.RunProc("delete from Cg_POInStockBillSub where HInterID='" + HInterID + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
                objJsonResult = AddBillSub(msg3, HInterID, OperationType,user);
                if (objJsonResult.code == "0")
                {
@@ -441,7 +464,7 @@
            }
        }
        public json AddBillSub(string msg3, long HInterID, int OperationType)
        public json AddBillSub(string msg3, long HInterID, int OperationType,string user)
        {
            List<ClsCg_POInStockBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_POInStockBillSub>>(msg3);
@@ -475,7 +498,7 @@
            string HPROJECTNO = DetailColl2[0].HPROJECTNO == null ? "''" : DetailColl2[0].HPROJECTNO;
            string HGIVEAWAY = DetailColl2[0].HGIVEAWAY == null ? "''" : DetailColl2[0].HGIVEAWAY;
            string HCHECKINCOMING = DetailColl2[0].HCHECKINCOMING == null ? "''" : DetailColl2[0].HCHECKINCOMING;
            string HDISCOUNTRATE = DetailColl2[0].HDISCOUNTRATE == null ? "''" : DetailColl2[0].HDISCOUNTRATE;
            string HDISCOUNTRATE = DetailColl2[0].HDISCOUNTRATE == null ? "'0'" : DetailColl2[0].HDISCOUNTRATE;
            double HPRICECOEFFICIENT = DetailColl2[0].HPRICECOEFFICIENT == null ? 0 : DetailColl2[0].HPRICECOEFFICIENT;
            long HPRICEUNITID = DetailColl2[0].HPRICEUNITID == null ? 0 : DetailColl2[0].HPRICEUNITID;
            long HPRICELISTENTRY = DetailColl2[0].HPRICELISTENTRY == null ? 0 : DetailColl2[0].HPRICELISTENTRY;
@@ -547,6 +570,18 @@
                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
                    NewHEntryID += 1;
                }
                //反写采购入库单
                string sReturn = "";
                ds = oCN.RunProcReturn("exec h_p_Cg_POOrderBillMain " + oSub.HQty + ", '" + oSub.HSourceInterID + "', '" + oSub.HSourceEntryID + "','" + user + " '", "h_p_Cg_POOrderBillMain");
                if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = sReturn;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc($@"Insert into Cg_POInStockBillSub 
                (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice
@@ -559,8 +594,9 @@
                ,HEXCHANGERATE,HLOCALCURRID,HISINCLUDEDTAX,HISPRICEEXCLUDETAX
                ,HTAXRATEID,HCOSTPERCENT,HCOSTAMOUNT,HVAT,HSELLERWITHHOLDING,HBUYERWITHHOLDING,HSecUnitID) 
                 values({HInterID},{NewHEntryID},{oSub.HMaterID},{oSub.HUnitID},{(oSub.HQty == null ? 0 : oSub.HQty)}
                ,{oSub.HPrice},{oSub.HMoney},{oSub.HWHID},{oSub.HSPID},'{HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},{HSourceBillNo},{HSourceBillType},{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID},{HPOOrderBillNo},{HAuxPropID},{HBatchNO},{HMTONo},{HPlanMode},{HERPInterID},{HERPEntryID},{HRelationQty},{HGiveAwayFlag},{HReceiveQty},{HSEQ},{HPRODUCEDATE},{HEXPIRYDATE},
                ,{oSub.HPrice},{oSub.HMoney},{oSub.HWHID},{oSub.HSPID},'{HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{HSourceBillNo}',{HSourceBillType},{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID},{HPOOrderBillNo},{HAuxPropID},{HBatchNO},{HMTONo},{HPlanMode},{HERPInterID},{HERPEntryID},{HRelationQty},{HGiveAwayFlag},{HReceiveQty},{HSEQ},{HPRODUCEDATE},{HEXPIRYDATE},
                  {HSUPPLYLOT},{HREQTRACENO},{HBOMID},{HSTOCKUNITID},{HBASEUNITID},{HSTOCKSTATUSID},'{HKEEPERTYPEID}',{HPROJECTNO},{HCHECKINCOMING},{oSub.HTaxPrice},{HDISCOUNTRATE},{HPRICECOEFFICIENT},{HPRICEUNITID},{HPRICELISTENTRY},{HSAMPLEDAMAGEQTY},{HSAMPLEDAMAGEBASEQTY},{HPAYORGID},{HSETTLEORGID},{HSETTLECURRID},{HSETTLEMODEID},{HEXCHANGETYPEID},{HPAYCONDITONID},{oSub.HEXCHANGERATE},{HLOCALCURRID},{HISINCLUDEDTAX},{HISPRICEEXCLUDETAX},{HTAXRATEID},{HCOSTPERCENT},{HCOSTAMOUNT},{HVAT},{HSELLERWITHHOLDING},{HBUYERWITHHOLDING},{oSub.HSecUnitID})");
            }
            objJsonResult.code = "1";
WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq;
using NPOI.SS.Formula.Functions;
using Pub_Class;
using System;
using System.Collections;
@@ -202,7 +203,7 @@
                    oCN.RunProc("delete from Kf_ICStockBillSub where HInterID='" + HInterID + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
                objJsonResult = AddBillSub(msg3, HInterID, OperationType, user);
                if (objJsonResult.code == "0")
                {
@@ -229,7 +230,7 @@
            }
        }
        public json AddBillSub(string msg3, long HInterID, int OperationType)
        public json AddBillSub(string msg3, long HInterID, int OperationType,string user)
        {
            List<ClsKf_ICStockBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ICStockBillSub>>(msg3);
@@ -312,6 +313,18 @@
                ,{(oSub.HPropertyID == null ? 0 : oSub.HPropertyID)},{(oSub.HSecUnitID == null ? 0 : oSub.HSecUnitID)},{(oSub.HSecUnitRate == null ? 0 : oSub.HSecUnitRate)}
                ,{(oSub.HPlanMode == null ? 0 : oSub.HPlanMode)},'{oSub.HRemark}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}')";
                string sReturn = "";
                ds = oCN.RunProcReturn("exec h_p_Cg_POInStockBillMain " + oSub.HQty + ", '" +oSub.HSourceInterID + "', '" + oSub.HSourceEntryID + "','" + user+" '", "h_p_Cg_POInStockBillMain");
                if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = sReturn;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc(sql);
            }
@@ -330,30 +343,81 @@
        /// <returns></returns>
        [Route("Kf_POStockInBill/DeltetKf_POStockInBill")]
        [HttpGet]
        public object DeltetKf_POStockInBill(string HInterID)
        public object DeleteKf_POStockInBackBill(string Hmainid, string HsupId, string HQty, string HSourceInterID, string HSourceEntryID, string user)
        {
            DataSet ds;
            DataSet dss;
            //string ModRightNameCheck = "Sc_ProcessReport_check";
            try
            {
                oCN.BeginTran();
                oCN.RunProc("Delete From Kf_ICStockBillMain  where HInterID = " + HInterID);
                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                //删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_POStockInBackBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (string.IsNullOrWhiteSpace(Hmainid))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "Hmainid为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();//开始事务
                ds = oCN.RunProcReturn("select * from Kf_ICStockBillMain a inner join Kf_ICStockBillSub b on a.HInterID=b.HInterID where a.HInterID= '"+ Hmainid+"'", "Kf_ICStockBillMain");
                dss = oCN.RunProcReturn("exec h_p_Cg_POInStockBillMain " + HQty + ", '" + HSourceInterID + "', '" + HSourceEntryID + "','" + user + " '", "h_p_Cg_POInStockBillMain");
                var sReturn = "";
                if (DBUtility.ClsPub.isLong(dss.Tables[0].Rows[0]["HBack"]) != 0)
                {
                    sReturn = DBUtility.ClsPub.isStrNull(dss.Tables[0].Rows[0]["HBackRemark"]).ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = sReturn;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有数据,无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                if (ds.Tables[0].Rows.Count  == 1)
                {
                    oCN.RunProc("delete Kf_ICStockBillSub where HInterID=" + Hmainid);
                    oCN.RunProc("delete Kf_ICStockBillMain where HInterID=" + Hmainid);
                }
                else
                {
                    oCN.RunProc($"delete Kf_ICStockBillSub where HInterID={ Hmainid}and HEntryID={HsupId}");
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.Message = "数据删除成功!";
                objJsonResult.data = null;
                return objJsonResult;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.Message = "删除失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 根据基础资料ID 查找记录