Ejemplo n.º 1
0
 private void ConfirmSave(List <Goods> toDeleteList, List <MapItems> toAddMIList, List <MapItems> toDeleteMIList)
 {
     //do as a transcaction
     using (TransactionScope trans = new TransactionScope())
     {
         Models.Service.IMapSingletonService mapSingletonService = Models.Service.MapSingletonService.Instance;
         mapSingletonService.GetMapItemsService().UpdateAllMapItems();
         mapSingletonService.GetMapItemsService().InserSpecialtMapItems(toAddMIList);
         mapSingletonService.GetMapItemsService().DeleteSpecialMapItems(toDeleteMIList);
         mapSingletonService.GetGoodsService().DeleteGoods(toDeleteList);
         trans.Complete();
     }
 }
Ejemplo n.º 2
0
 private void ExecuteSaveAllCommandDo()
 {
     using (TransactionScope trans = new TransactionScope())
     {
         Models.Service.IMapSingletonService mapSingletonService = Models.Service.MapSingletonService.Instance;
         mapSingletonService.GetZonesService().UpdateZones();
         //need to set all deleted zones' id of certain mapitems
         foreach (Models.Entity.Zone z in _deleteZones)
         {
             List <Models.Entity.MapItems> delitems = _map.MapItems.Where(mi => mi.ZoneId == z.Id).ToList();
             foreach (Models.Entity.MapItems mi in delitems)
             {
                 mi.ZoneId = 0;
             }
         }
         mapSingletonService.GetMapItemsService().UpdateAllMapItems();
         mapSingletonService.GetZonesService().DeleteZones(_deleteZones);
         trans.Complete();
         MessageBoxResult confirmToDel = MessageBox.Show(Localiztion.Resource.ModifySelectedMapItem_GoodsTypes_Complete);
         if (confirmToDel == MessageBoxResult.OK)
         {
             _self.Close();
         }
     }
 }
        virtual protected void ExecuteModifySelectedStorageCommandDo()
        {
            //first to pick all the MapItems as a list
            //then create a new list of goods
            //create goods
            //save goods--> transaction
            //save map-- transaction
            //over
            List <Models.Entity.Goods> addList    = new List <Models.Entity.Goods>();
            List <Models.Entity.Goods> deleteList = new List <Models.Entity.Goods>();

            for (int i = 0; i < SelectedStorages.Count; i++)
            {
                addList.Add(new Models.Entity.Goods()
                {
                    Name           = GoodName,
                    Batch          = GoodBatch,
                    Model          = GoodModel,
                    Count          = _goodCount,
                    MapItemsId     = SelectedStorages[i].SingleStorage.MapItemID,
                    CargoWayLockId = 0,
                    //TODO::set GoodId and BarCode interfaces
                    ProductId = "",
                    BarCode   = ""
                });
            }
            using (TransactionScope scope = new TransactionScope())
            {
                Models.Service.IMapSingletonService mapSingletonService = Models.Service.MapSingletonService.Instance;
                for (int i = 0; i < SelectedStorages.Count; i++)
                {
                    Models.Entity.Goods todel = _map.Goods.SingleOrDefault(g => g.MapItemsId == SelectedStorages[i].SingleStorage.MapItemID);
                    if (todel != null && todel.Id != 0)
                    {
                        deleteList.Add(todel);
                    }
                }
                //先删除,后赋值保存
                mapSingletonService.GetGoodsService().DeleteGoods(deleteList);
                mapSingletonService.GetGoodsService().InsertGoods(addList);
                //存储栅格状态
                mapSingletonService.GetMapItemsService().UpdateAllMapItems();
                scope.Complete();
                refreshGridColorCallBack();
                StringBuilder sb = new StringBuilder();
                sb.Append("Delete ").Append(deleteList.Count).Append(" goods. And add ")
                .Append(addList.Count).Append(" new goods.");
                mainStatusCallBack(sb.ToString());
                _self.Close();
            }
        }