llj
2025-08-07 1a94e0e270668ef1cfbcd5043b72bc6591a50706
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_MouldStatusController.cs
@@ -59,6 +59,46 @@
        }
        #endregion
        #region  å™¨å…·çŠ¶æ€ ç¼–辑初始化
        [Route("Gy_MouldStatus/Gy_MouldStatusEditInit")]
        [HttpGet]
        public object Gy_MouldStatusEditInit(string sWhere, string user, string Organization)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = string.Format(@"select * from h_v_Gy_MouldStatus_Edit where ä½¿ç”¨ç»„织='" + Organization + "'");
                string sql = sql1 + sWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Gy_MouldStatus_Edit");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region  å™¨å…·çŠ¶æ€ ç¼–辑
        [Route("Gy_MouldStatus/Gy_MouldStatusEdit")]
        [HttpPost]
@@ -103,7 +143,7 @@
                    }
                    //查询数据中是否存在重复代码
                    ds = oCN.RunProcReturn("select * from  Gy_MouldStatus where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_MouldStatus");
                    ds = oCN.RunProcReturn("select * from  Gy_MouldStatus where HNumber='" + oItem.HNumber.Trim() + "' and HUSEORGID= " + oItem.HUSEORGID, "Gy_MouldStatus");
                    if (oItem.HItemID == 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
@@ -413,5 +453,99 @@
        }
        #endregion
        #region å™¨å…·çŠ¶æ€ ç¦ç”¨ã€åç¦ç”¨
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsStop">禁用(0),反禁用(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Gy_MouldStatus/StopGy_MouldStatus")]
        [HttpGet]
        public object StopGy_MouldStatus(int HInterID, int IsStop, string CurUserName)
        {
            try
            {
                ////审核权限
                //if (!DBUtility.ClsPub.Security_Log_second("Gy_MouldStatus_Stop", 1, false, CurUserName))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "禁用失败!无权限!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                var ds = oCN.RunProcReturn("select * from Gy_MouldStatus where HItemID=" + HInterID, "Gy_MouldType");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (IsStop == 0)  //禁用判断
                    {
                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "已禁用!不能再次禁用!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsStop == 1) //反禁用判断
                    {
                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未禁用!不需要反禁用!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "数据不存在!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                if (IsStop == 0)  //禁用判断
                {
                    oCN.RunProc("update Gy_MouldStatus set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "禁用成功";
                    objJsonResult.data = null;
                }
                if (IsStop == 1) //反禁用判断
                {
                    oCN.RunProc("update Gy_MouldStatus set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "反禁用成功";
                    objJsonResult.data = null;
                }
                oCN.Commit();
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "禁用失败或者反禁用失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}