yangle
2024-06-29 da1bf9f968a95b773b0dff98b45197dc80c7ae63
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -1156,6 +1156,34 @@
        }
        #endregion
        #region[器具档案编辑时获取子表数据]
        [Route("Gy_MouldFileMain/Gy_MouldFileSubDetai")]
        [HttpGet]
        public object Gy_MouldFileSubDetai(long HInterID)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                ds = oCN.RunProcReturn("select a.*,b.HBillNo from Gy_MouldFileSub_MaintainRule AS a left join Sc_MouldMaintainRuleBillMain as b on b.HInterID = a.HMaintainRuleID where a.HInterID = " + HInterID, "Gy_MouldFileBill_MaintainRule");
                tableList.Add(ds.Tables[0]);
                ds = oCN.RunProcReturn("select a.*,b.HBillNo from Gy_MouldFileSub_DotCheckRule AS a left join Sc_MouldDotCheckRuleBillMain as b on b.HInterID = a.HDotCheckRuleID where a.HInterID = " + HInterID, "Gy_MouldFileBill_DotCheckRule");
                tableList.Add(ds.Tables[0]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 新增模具档案-保存按钮
        ///参数:string sql。
@@ -1185,7 +1213,6 @@
            objJsonResult = AddBillMain(msg1);
            if (objJsonResult.code == "0")
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = objJsonResult.Message;
@@ -1206,6 +1233,8 @@
            string msg3 = sArray[1].ToString();//模块权限
            string msg4 = sArray[2].ToString();//当前人
            string msg5 = sArray[3].ToString();//子表数据
            string msg6 = sArray[4].ToString();//子表1数据
            string msg7 = sArray[5].ToString();//子表2数据
            try
            {
                msg2 = "[" + msg2.ToString() + "]";
@@ -1295,7 +1324,7 @@
                ",0,0,'','',0,0 " +
                ") ");
                objJsonResult = AddBillSub(msg5,HInterID, HBillNo);
                objJsonResult = AddBillSub(msg5,msg6,msg7,HInterID, HBillNo);
                if (objJsonResult.code == "0")
                {
@@ -1314,6 +1343,7 @@
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
@@ -1339,6 +1369,8 @@
            string msg3 = sArray[1].ToString();//模块权限
            string msg4 = sArray[2].ToString();//当前人
            string msg5 = sArray[3].ToString();//子表数据
            string msg6 = sArray[4].ToString();//子表2数据
            string msg7 = sArray[5].ToString();//子表3数据
            try
            {
                if (!DBUtility.ClsPub.Security_Log(msg3, 1, false, msg4))
@@ -1471,8 +1503,9 @@
                // oCN.RunProc("Update Gy_Department set HEndflag=0 where HItemID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                oCN.RunProc("delete from Gy_MouldFileSub_SubMater where HInterID='" + HInterID + "'");
                objJsonResult = AddBillSub(msg5, HInterID, HBillNo);
                oCN.RunProc("delete from Gy_MouldFileSub_MaintainRule where HInterID='" + HInterID + "'");
                oCN.RunProc("delete from Gy_MouldFileSub_DotCheckRule where HInterID='" + HInterID + "'");
                objJsonResult = AddBillSub(msg5, msg6, msg7, HInterID, HBillNo);
                oCN.Commit();
                objJsonResult.code = "1";
@@ -1492,9 +1525,12 @@
            }
        }
        public json AddBillSub(string msg5, long HInterID, string HBillNo)
        public json AddBillSub(string msg5, string msg6, string msg7, long HInterID, string HBillNo)
        {
            List<Gy_MouldFileSub_SubMater> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_MouldFileSub_SubMater>>(msg5);
            List<ClsGy_MouldFileBillSub_MaintainRule> MaintainRuleColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_MouldFileBillSub_MaintainRule>>(msg6);
            List<ClsGy_MouldFileBillSub_DotCheckRule> DotCheckRuleColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_MouldFileBillSub_DotCheckRule>>(msg7);
            int i = 0;                                          //作为子表内码
            foreach (Gy_MouldFileSub_SubMater oSub in DetailColl)
            {
@@ -1517,6 +1553,50 @@
                    "')";
                oCN.RunProc(sql);
            }
            i = 0;
            //保存保养规格
            foreach (ClsGy_MouldFileBillSub_MaintainRule oSub in MaintainRuleColl)
            {
                i++;
                Int64 NewHEntryID = i;
                Int64 newHFlag = 1;
                if (oSub.HStdFlag == true)
                {
                    newHFlag = 1;
                }
                else
                {
                    newHFlag = 0;
                }
                oCN.RunProc($@"Insert into Gy_MouldFileSub_MaintainRule
                (HInterID,HBillNo_bak,HEntryID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,
                 HMaintainRuleID,HStdFlag
               )
                 values({HInterID},'{HBillNo}',{NewHEntryID},'{oSub.HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney}
                ,{oSub.HMaintainRuleID},{newHFlag})");
            }
            i = 0;
            //保存点检规程
            foreach (ClsGy_MouldFileBillSub_DotCheckRule oSub in DotCheckRuleColl)
            {
                i++;
                Int64 NewHEntryID = i;
                Int64 newHFlag = 1;
                if (oSub.HStdFlag == true)
                {
                    newHFlag = 1;
                }
                else
                {
                    newHFlag = 0;
                }
                oCN.RunProc($@"Insert into Gy_MouldFileSub_DotCheckRule
                (HInterID,HBillNo_bak,HEntryID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,
                 HDotCheckRuleID,HStdFlag
               )
                 values({HInterID},'{HBillNo}',{NewHEntryID},'{oSub.HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney}
                ,{oSub.HDotCheckRuleID},{newHFlag})");
            }
            objJsonResult.code = "1";
@@ -1612,6 +1692,8 @@
                }
                if (oBill.DeleteBill(hmainid, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    oCN.RunProc("Delete From Gy_MouldFileSub_MaintainRule  where HInterID=" + hmainid);
                    oCN.RunProc("Delete From Gy_MouldFileSub_DotCheckRule  where HInterID=" + hmainid);
                    //写入日志
                    ClsPub.Add_Log("", "删除项目,代码:" + oBill.omodel.HMouldNo + ",名称:" + oBill.omodel.HName, ClsPub.CurUserName);
                    //更新上级为 末级