1
wtt
2025-05-26 cab9c912a2a4ea3e45c1e8d1507efd5fa5fda4ac
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_MatePriceSupController.cs
@@ -27,15 +27,15 @@
            {
                List<object> columnNameList = new List<object>();
                //编辑权限
                //if (!DBUtility.ClsPub.Security_Log_second("Gy_TaxRate_Query", 1, false, user))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "无查看权限!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                string sql1 = string.Format(@"select * from h_v_Gy_MatePriceSupList where 1 = 1 ");
                if (!DBUtility.ClsPub.Security_Log_second("Gy_MatePriceSupList_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql1 = string.Format(@"select * from h_v_Gy_MatePriceSupList_Sec where 1 = 1 ");
                string sql = sql1 + sWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Gy_MatePriceSupList");
@@ -66,6 +66,45 @@
        }
        #endregion
        #region  é‡‡è´­ä»·æ ¼ ç¼–辑查看信息
        [Route("Gy_MatePriceSup/cx")]
        [HttpGet]
        public object cx(string HItemID, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("Gy_MatePriceSupList_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql1 = string.Format(@"select * from h_v_Gy_MatePriceSupEdit where HItemID = " + HItemID);
                ds = oCN.RunProcReturn(sql1, "h_v_Gy_MatePriceSupEdit");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                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_MatePriceSup/MatePriceSupEdit")]
        [HttpPost]
@@ -77,19 +116,16 @@
            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg1 = sArray[0].ToString();
            string msg2 = sArray[1].ToString();
            //string msg_HUSEORGID = sArray[2].ToString();
            Int64 HItemID = 0;
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            //编辑权限
            //if (!DBUtility.ClsPub.Security_Log_second("Gy_TaxRate_Edit", 1, false, msg2))
            //{
            //    objJsonResult.code = "0";
            //    objJsonResult.count = 0;
            //    objJsonResult.Message = "无保存权限!";
            //    objJsonResult.data = null;
            //    return objJsonResult;
            //}
            if (!DBUtility.ClsPub.Security_Log_second("Gy_MatePriceSupList_Edit", 1, false, msg2))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "无保存权限!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            //获取最大ID值赋值
            //DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_TaxRate ", "Gy_TaxRate");
@@ -186,6 +222,16 @@
                }
                else
                {
                    //是否已经审核判断
                    DataSet Maxds = oCN.RunProcReturn("select * from h_v_Gy_MatePriceSupEdit where HItemID =  " + oBill.oModel.HItemID, "h_v_Gy_MatePriceSupEdit");
                    if (Maxds != null && Maxds.Tables[0].Rows[0]["审核人"].ToString()!="")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已审核无法编辑!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
                }
                if (bResult)
@@ -227,14 +273,14 @@
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                //删除权限
                //if (!DBUtility.ClsPub.Security_Log("Gy_TaxRate_Drop", 1, false, user))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "无删除权限";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (!DBUtility.ClsPub.Security_Log("Gy_MatePriceSupList_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HItemID))
                {
                    objJsonResult.code = "0";
@@ -254,15 +300,15 @@
                    return objJsonResult; ;
                }
                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                //if (HStopflag)
                //{
                //    oCN.RollBack();//回滚事务
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "数据已禁用无法删除!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (ds.Tables[0].Rows[0]["HChecker"].ToString()!="")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "数据已审核无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc("delete from Gy_MatePriceSup where HItemID=" + HItemID);
                oCN.Commit();//提交事务
@@ -328,5 +374,157 @@
            }
        }
        #endregion
        #region å®¡æ ¸ã€åå®¡æ ¸
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Gy_MatePriceSup/CheckGy_MatePriceSup")]
        [HttpGet]
        public object CheckGy_MatePriceSup(long HInterID, int IsAudit, string CurUserName)
        {
            try
            {
                //审核权限
                if (!DBUtility.ClsPub.Security_Log_second("Gy_MatePriceSupList_Check", 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "审核失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                var ds = oCN.RunProcReturn("select * from Gy_MatePriceSup where HItemID=" + HInterID, "Gy_MatePriceSup");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (IsAudit == 0)  //审核判断
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能再次审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反审核判断
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"].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 (IsAudit == 0)  //审核判断
                {
                    oCN.RunProc("update Gy_MatePriceSup set HChecker='" + CurUserName + "',HCheckDate=getdate() where HItemID=" + HInterID);
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核成功";
                    objJsonResult.data = null;
                }
                if (IsAudit == 1) //反审核判断
                {
                    oCN.RunProc("update Gy_MatePriceSup set HChecker='',HCheckDate=null 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
        #region æ‰¹é‡å®¡æ ¸
        /// <summary>
        /// æ‰¹é‡å®¡æ ¸
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="Type">审核(0),反审核(1)</param>
        /// <param name="HMaker">审核人</param>
        /// <returns></returns>
        [Route("Gy_MatePriceSup/CheckAll")]
        [HttpGet]
        public object CheckAll(string ids, int Type, string HMaker)
        {
            try
            {
                //处理字符串
                if (!string.IsNullOrEmpty(ids))
                {
                    long[] idArray = Array.ConvertAll(ids.Split(','), long.Parse);
                    // å¤„理idArray...
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        objJsonResult = (json)CheckGy_MatePriceSup(idArray[i], Type, HMaker);//审核执行
                        if (objJsonResult.count == 0)
                        {
                            objJsonResult.Message += "第" + (i + 1) + "行出现问题无法继续完成";
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "请选择正确行";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核或反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}