Exemple #1
0
        private async void OnSelectDiscount(DiscountDto obj)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                // Thuc hien cong viec tai day
                if (InvoiceBindProp == null)
                {
                    InvoiceBindProp = new InvoiceDto();
                }
                var discount = new DiscountForInvoiceDto(obj);
                if (obj.IsPercentage)
                {
                    discount.Value = obj.Value / 100 * InvoiceBindProp.TotalPrice;
                }
                InvoiceBindProp.Discounts.Add(discount);
                InvoiceBindProp.TotalPrice -= discount.Value;
            }
            catch (Exception e)
            {
                await ShowErrorAsync(e);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        private async void OnSave(object obj)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                // Thuc hien cong viec tai day
                ItemForInvoiceBindProp.Value += ItemBindProp.Price * ItemForInvoiceBindProp.Quantity;

                ListDiscountBindProp.Where(d => d.IsSelected).OrderBy(d => d.IsPercentage).ForEach(discount =>
                {
                    discount.IsSelected = false;
                    if (discount.IsPercentage)
                    {
                        var newDiscount   = new DiscountForInvoiceDto(discount);
                        newDiscount.Value = discount.Value / 100 * ItemForInvoiceBindProp.Value;
                        ItemForInvoiceBindProp.Discounts.Add(newDiscount);
                        ItemForInvoiceBindProp.Value -= newDiscount.Value;
                    }
                    else
                    {
                        ItemForInvoiceBindProp.Discounts.Add(new DiscountForInvoiceDto(discount));
                        ItemForInvoiceBindProp.Value -= discount.Value;
                    }
                });
                var param = new NavigationParameters();
                param.Add("item", ItemForInvoiceBindProp);
                await NavigationService.GoBackAsync(param);
            }
            catch (Exception e)
            {
                await ShowErrorAsync(e);
            }
            finally
            {
                IsBusy = false;
            }
        }