示例#1
0
        //刪除沒有商品佔據的主料位
        public HttpResponseBase DeleteIplasById()
        {
            string jsonStr = String.Empty;
            _IlocMgr = new IlocMgr(mySqlConnectionString);
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            Iloc loc = new Iloc();
            IplasQuery plasQuery = new IplasQuery();
            IinvdQuery nvdQery = new IinvdQuery();
            try
            {
                string str = Request.Params["loc_id"].ToString().ToUpper();//獲取類型
                str = str.Substring(0, str.LastIndexOf(","));
                int sum = 0;
                string[] strs = str.Split(',');
                for (int i = 0; i < strs.Length; i++)
                {
                    nvdQery.loc_id = strs[i];
                    sum = sum + _IiplasMgr.GetIinvdItemId(nvdQery);
                }
                if (sum > 0)
                {
                    jsonStr = "{success:true,sum:" + sum + "}";//大於0表示算選包含庫存量
                }
                else
                {
                    int counts = 0;
                    for (int i = 0; i < strs.Length; i++)
                    {
                        plasQuery.loc_id = strs[i];
                        counts = counts + _IiplasMgr.DeleteIplasById(plasQuery);
                    }

                    if (counts > 0)
                    {
                        jsonStr = "{success:true,count:" + counts + "}";
                    }
                    else
                    {
                        jsonStr = "{success:false}";
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }