Ejemplo n.º 1
0
        public bool AddGoods(Goods good, out string result)
        {
            if (GoodsList.Exists(c => c.area_id == good.area_id &&
                                 c.width == good.width &&
                                 c.length == good.length &&
                                 (c.color.Equals(good.color) || c.name.Equals(good.name))))
            {
                result = "已经存在一样的规格的信息了!";
                return(false);
            }

            if (!Monitor.TryEnter(_go, TimeSpan.FromSeconds(2)))
            {
                result = "";
                return(false);
            }

            try
            {
                uint goodid = PubMaster.Dic.GenerateID(DicTag.NewGoodId);
                good.id = goodid;
                good.GoodCarrierType = PubMaster.Area.GetCarrierType(good.area_id);
                PubMaster.Mod.GoodSql.AddGoods(good);
                GoodsList.Add(good);
                SendMsg(good, ActionTypeE.Add);
                PubMaster.Dic.UpdateVersion(DicTag.PDA_GOOD_VERSION);
                result = "";
                return(true);
            }
            finally
            {
                Monitor.Exit(_go);
            }
        }