Exemplo 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);
            }
        }
Exemplo n.º 2
0
        private void FillItemListWithTestData()
        {
            var bus = new Goods
            {
                Id            = 1,
                Name          = "Bus",
                Description   = "School bus",
                Cost          = 50000,
                Image         = "/cars/icons8-bus-64.png",
                ButtonContent = ButtonAction.Buy
            };
            var limousine = new Goods
            {
                Id            = 2,
                Name          = "Limousine",
                Description   = "Elite class",
                Cost          = 10000,
                Image         = "/cars/icons8-limousine-filled-50.png",
                ButtonContent = ButtonAction.Buy
            };
            var pickup = new Goods
            {
                Id            = 3,
                Name          = "Pickup",
                Description   = "Workhorse",
                Cost          = 20000,
                Image         = "/cars/icons8-pickup-48.png",
                ButtonContent = ButtonAction.Buy
            };
            var suv = new Goods
            {
                Id            = 4,
                Name          = "Suv",
                Description   = "Sport class",
                Cost          = 35000,
                Image         = "/cars/icons8-suv-48.png",
                ButtonContent = ButtonAction.Buy
            };
            var tesla = new Goods
            {
                Id            = 5,
                Name          = "Tesla",
                Description   = "Electric car",
                Cost          = 50000,
                Image         = "/cars/icons8-tesla-model-x-filled-50.png",
                ButtonContent = ButtonAction.Buy
            };

            GoodsList.Add(bus);
            GoodsList.Add(limousine);
            GoodsList.Add(pickup);
            GoodsList.Add(suv);
            GoodsList.Add(tesla);

            foreach (var goods in GoodsList)
            {
                goods.ActionEvent     += () => ActionEvent(goods);
                goods.PropertyChanged += GoodsPropertyChanged;
            }
        }
Exemplo n.º 3
0
 public void AddOrderItem(OrderItem o)
 {
     GoodsList.Add(o);
 }