示例#1
0
        public SalesUpdateAddItemViewModel(IDialogService ids, IItemDatabase iid)
        {
            dialog = ids;
            itemDb = iid;
            if (GlobalVars.selectedSalesItem == null)
            {
                loadItemCatalogue();
                IsTextboxesEnabled = false;
                IsDiscPercent      = false;
                IsDiscAmount       = false;

                RaisePropertyChanged(() => IsTextboxesEnabled);
                RaisePropertyChanged(() => IsDiscAmount);
                RaisePropertyChanged(() => IsDiscPercent);
            }
            else
            {
                Task.Run(async() =>
                {
                    var itemDetail = await itemDb.GetItemDetail(GlobalVars.selectedSalesItem.ItemId);
                    ItemCatalogue  = new ObservableCollection <SalesItemSelection>();
                    var itemTemp   = new SalesItemSelection(GlobalVars.selectedSalesItem.ItemId, GlobalVars.selectedSalesItem.ItemName, GlobalVars.selectedSalesItem.ActualPrice,
                                                            GlobalVars.selectedSalesItem.UnitMeasurement, itemDetail.Barcode);
                    ItemCatalogue.Add(itemTemp);

                    SelectedItem       = itemTemp;
                    Quantity           = GlobalVars.selectedSalesItem.Quantity;
                    DiscAmount         = GlobalVars.selectedSalesItem.DiscountAmount.ToString();
                    DiscPercent        = GlobalVars.selectedSalesItem.DiscountPercentage.ToString();
                    IsTextboxesEnabled = true;
                    IsDiscAmount       = true;
                    RaisePropertyChanged(() => Quantity);
                    RaisePropertyChanged(() => DiscAmount);
                    RaisePropertyChanged(() => DiscPercent);
                    RaisePropertyChanged(() => IsDiscAmount);
                    RaisePropertyChanged(() => IsTextboxesEnabled);
                    refreshTotal();
                });
            }
        }