王 垚
2022-11-30 5ca523ad4bc92a240ed4844994236cc8281ea90b
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -194,32 +194,22 @@
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim()))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim()))
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                    //    objJsonResult.data = 1;
                    //    return objJsonResult;
                    //}
                    //查询数据中是否存在重复代码
                    ds = oCN.RunProcReturn("select * from  Gy_Material where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_Material");
                    if (oItem.HNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //新增时判断
                    #region 父级校验方法(api调用先注释掉,)
                    /*
                    if (oItem.HItemID == 0)
                    {
                        if (ds == null || ds.Tables[0].Rows.Count == 0)
                        {
                        }
                        else
                        if (ds == null || ds.Tables[0].Rows.Count > 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
@@ -275,6 +265,8 @@
                            }
                        }
                    }
                    */
                    #endregion
                    //得到短代码
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
@@ -292,13 +284,12 @@
                    oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //等级
                    oBill.oModel = oItem;
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.oModel.HItemID == 0)
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    //bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddNew();
                }
                else
@@ -333,7 +324,52 @@
            }
        }
        [Route("Gy_Material/SaveGy_MaterialListApi")]
        [HttpPost]
        public object SaveGy_MaterialListApi([FromBody] JObject msg)
        {
            var _value = msg["model"].ToString();
            string msg3 = _value.ToString();
            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg1 = sArray[0].ToString();
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            ListModels oListModels = new ListModels();
            try
            {
                DLL.ClsGy_Material_Ctl oBill = new DLL.ClsGy_Material_Ctl();
                List<Models.ClsGy_Material_Model> lsmain = new List<Models.ClsGy_Material_Model>();
                msg1 = msg1.Replace("\\", "");
                msg1 = msg1.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Gy_Material(msg1);
                oBill.oModel = lsmain[0];
                //保存
                bool bResult = oBill.AddNewApi();
                if (bResult)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 物料设置删除功能