duhe
2024-05-28 fa8f01640eab5b5dfa66f91daa28112c44877b61
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -993,6 +993,157 @@
        }
        #endregion
        #region 条码主档维护 作废/反作废
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">作废(0),反作废(1)</param>
        /// <param name="CurUserName">作废人</param>
        /// <returns></returns>
        [Route("Gy_BarCodeBillList/DeleteGy_BarCodeBillList")]
        [HttpGet]
        public object DeleteGy_BarCodeBillList(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Gy_BarCodeBillList_Delete";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "作废失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                //进行需要进行的作废/反作废操作
                if (IsAudit == 0) //作废提交
                {
                    oCN.BeginTran();
                    //作废条码
                    oCN.RunProc("update Gy_BarCodeBill set HStopflag=1,HDeleteMan='" + CurUserName + "',HDeleteDate=getdate() where HItemID in (" + HInterID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                    string sql = "select * from Gy_BarCodeBill where HItemID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, "Gy_BarCodeBill");
                    if(ds!=null && ds.Tables[0].Rows.Count > 0)
                    {
                        string HBarCode = ds.Tables[0].Rows[0]["HBarCode"].ToString();
                        //添加操作日志
                        oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','作废条码:" + HBarCode + "','WMS系统-条码档案列表模块','" + DBUtility.ClsPub.IPAddress + "','作废'", ref DBUtility.ClsPub.sExeReturnInfo);
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废成功";
                        objJsonResult.data = null;
                        oCN.Commit();
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "作废失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        oCN.RollBack();
                    }
                    return objJsonResult;
                }
                if (IsAudit == 1) //反关闭提交
                {
                    oCN.BeginTran();
                    #region 反作废条码前进行判断
                    //反作废条码前进行判断------------------------------------------------------------------------------------------------------------------------------------------------------
                    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    DataSet DS = oCN.RunProcReturn("exec h_p_Gy_BarCodeBill_UnCancelltion '" + HInterID + "','N'", "h_p_Gy_BarCodeBill_UnCancelltion", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DS == null || DS.Tables[0].Rows.Count <= 0)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反作废失败,原因:反作废条码前判断发生错误!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0][0]) == "1")
                        {
                            oCN.RollBack();
                            objJsonResult.code = "1";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "反作废失败,原因:" + DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HRemark"]);
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    #endregion
                    //反作废条码
                    oCN.RunProc("update Gy_BarCodeBill set HStopflag=0,HDeleteMan='',HDeleteDate=null where HItemID in (" + HInterID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                    //增加操作日志
                    string sql = "select * from Gy_BarCodeBill where HItemID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, "Gy_BarCodeBill");
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        string HBarCode = ds.Tables[0].Rows[0]["HBarCode"].ToString();
                        oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','反作废条码:" + HBarCode + "','WMS系统-条码档案列表模块','" + DBUtility.ClsPub.IPAddress + "','反作废'", ref DBUtility.ClsPub.sExeReturnInfo);
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废成功";
                        objJsonResult.data = null;
                        oCN.Commit();
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反作废失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "作废失败或者反作废失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 新增模具档案-保存按钮