Beispiel #1
0
        private void BillItem_OnItemDeleted(BillItemVM obj)
        {
            this.BillItemVMList.Remove(obj);
            var dmObj =this.DomainBill.BillItemList.FirstOrDefault(x => x.ProductId == obj.DomainBillItem.ProductId);

            if (dmObj != null)
            {
                this.DomainBill.BillItemList.Remove(dmObj);
            }
            vm_PropertyChanged(null, null);
        }
Beispiel #2
0
         internal void Add(Product.ProductItemViewModel productVm)
         {
             var targetItem =this.BillItemVMList.SingleOrDefault(x => x.ProductCode == productVm.DomainProduct.Code);
             if (targetItem != null)
             {
                 targetItem.DomainBillItem.SellPrice = productVm.SellPrice;
                 targetItem.DomainBillItem.Count++;
             }
             else
             {

                 var dmObj = new domain.BillItem()
                 {
                     ProductId = productVm.DomainProduct.ID,
                     Count = 1,
                     SellPrice = productVm.SellPrice
                 };

                 var vmObj = new BillItemVM(productVm.DomainProduct.Brand + "->" + productVm.DomainProduct.Name,
                     productVm.DomainProduct.Spec,
                     productVm.DomainProduct.Code,
                     productVm.DomainProduct.GrossWeight,
                     dmObj);

                 vmObj.OnItemDeleted += new Action<BillItemVM>(BillItem_OnItemDeleted);
                 vmObj.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(vm_PropertyChanged);
                 dmObj.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(item_PropertyChanged);

                 this.DomainBill.BillItemList.Add(dmObj);

                 this.BillItemVMList.Add(vmObj);
             }
             RaisePropertyChanged("Summary");
             RaisePropertyChanged("WeightSummary"); 
         }
Beispiel #3
0
        private ObservableCollection<BillItemVM> BuildBillItemVmList(domain.Bill bill)
        {
            List<BillItemVM> retList = new List<BillItemVM>();


            foreach (var item in bill.BillItemList)
            {
                domain.Product product = productService.GetAllProduct().SingleOrDefault(x => x.ID == item.ProductId);

                if(product == null) continue;

                BillItemVM vm = new BillItemVM(product.Brand +"->"+product.Name, product.Spec, product.Code, product.GrossWeight, item);
                vm.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(vm_PropertyChanged);
                vm.OnItemDeleted += new Action<BillItemVM>(BillItem_OnItemDeleted);
                item.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(item_PropertyChanged);
                retList.Add(vm);
            }

            return new ObservableCollection<BillItemVM>(retList);
        }