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 查找记录