Example #1
0
        public bool DeleteGood(uint goodid, out string result)
        {
            if (PubMaster.Device.ExistDevByGid(goodid))
            {
                result = "砖机配置了该规格!";
                return(false);
            }

            if (PubMaster.Goods.ExistStockInTrackByGid(goodid))
            {
                result = "储砖库存内有该规格";
                return(false);
            }

            if (!Monitor.TryEnter(_go, TimeSpan.FromSeconds(2)))
            {
                result = "";
                return(false);
            }
            try
            {
                Goods gs = GetGoods(goodid);
                if (gs != null)
                {
                    DeleteStockByGid(goodid);
                    Thread.Sleep(500);

                    PubMaster.Mod.GoodSql.DeleteGoods(gs);
                    GoodsList.Remove(gs);
                    SendMsg(gs, ActionTypeE.Delete);
                    result = "删除成功:" + gs.name;
                    return(true);
                }
            }
            finally { Monitor.Exit(_go); }

            result = "删除失败!";
            return(false);
        }