コード例 #1
0
        public PagoValeExternoViewModel()
        {
            this.PlanPago         = new ObservableCollection <Models.PlanPagoItem>();
            this.PropertyChanged += PagoValeExternoViewModel_PropertyChanged;
            if (!IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }

            this.SearchCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                this.Vale = _proxy.FindDistribuidorExterno(this.SelectedNegocio.Value, this.Cuenta, this.ValeSearch);
                if (this.Vale == null)
                {
                    MessageBox.Show("Distribuidor no encontrado.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }, () => !string.IsNullOrEmpty(this.ValeSearch) && this.SelectedNegocio.HasValue && !string.IsNullOrEmpty(this.Cuenta));

            if (!this.IsInDesignMode)
            {
                var settings = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>();
                this.Promocion = _proxy.FindPromocionesVale(settings.Sucursal.Clave);
                this.Negocios  = _proxy.GetNegocios();
            }

            if (this.IsInDesignMode)
            {
                this.Plazos        = new int[] { 1, 2, 3 };
                this.SelectedPlazo = 3;
                this.Promocion     = new PromocionesValeResponse
                {
                    Promociones = new DateTime[] {
                        DateTime.Parse("2019-01-01"),
                        DateTime.Parse("2019-02-10"),
                        DateTime.Parse("2019-03-20")
                    },
                    Fechas = new DateTime[] {
                        DateTime.Parse("2020-01-01"),
                        DateTime.Parse("2020-02-10"),
                        DateTime.Parse("2020-03-20")
                    },
                    Blindaje = 100
                };
                this.SelectedPromocion = this.Promocion.Promociones.Last();
                this.Primero           = 123;
                this.Ultimo            = 456;
                this.Pagar             = 100m;
                this.ValeSearch        = "vale";
                this.Negocios          = new Common.Entities.NegocioExterno[]
                {
                    new Common.Entities.NegocioExterno {
                        Id = 1, Negocio = "a", Descripcion = "n1"
                    },
                    new Common.Entities.NegocioExterno {
                        Id = 2, Negocio = "b", Descripcion = "n2"
                    },
                    new Common.Entities.NegocioExterno {
                        Id = 3, Negocio = "c", Descripcion = "n3"
                    }
                };
                this.Negocio         = "a";
                this.SelectedNegocio = 1;
                this.Cuenta          = "0123456";
                this.Vale            = new Common.Entities.ValeResponse
                {
                    Cancelado       = true,
                    CanceladoMotivo = "motivo",
                    Disponible      = 199m,
                    Vale            = "123",
                    ClienteId       = 1,
                    Distribuidor    = new Common.Entities.Distribuidor
                    {
                        Id          = 1,
                        Cuenta      = "0123",
                        Nombre      = "nombre",
                        ApPaterno   = "appaterno",
                        ApMaterno   = "apmaterno",
                        Status      = Common.Constants.StatusDistribuidor.SOBREGIRADO,
                        Electronica = true,
                        Promocion   = true,
                        ContraVale  = true,
                        Firmas      = new short[] { 1, 2, 3 }
                    }
                };
            }
        }
コード例 #2
0
        public PagoValeDigitalViewModel()
        {
            if (!IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.PropertyChanged += PagoValeViewModel_PropertyChanged;
            this.SearchCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy = true;
                this.Vale   = await _proxy.FindValeDigitalAsync(this.Search);
                if (this.Vale != null)
                {
                    this.Search = null;
                    if (!this.Vale.Distribuidor.Promocion)
                    {
                        this.SelectedPromocion = this.Promociones.FirstOrDefault();
                    }
                }
                else
                {
                    MessageBox.Show("not found");
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.Search));

            if (!this.IsInDesignMode)
            {
                var settings  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>();
                var promocion = _proxy.FindPromocionesVale(settings.Sucursal.Clave);
                if (promocion != null)
                {
                    //this.Plazos = promocion.Plazos;
                    //this.SelectedPlazo = promocion.Selected;
                    this.PagosMax    = promocion.PagosMax;
                    this.Promociones = promocion.Promociones;
                    //this.SelectedPromocion = promocion.Promociones.Any() ? promocion.Promociones.Last() : (DateTime?)null;
                }
            }

            if (this.IsInDesignMode)
            {
                this.Plazos        = new int[] { 1, 2, 3 };
                this.SelectedPlazo = 3;
                this.PagosMax      = 10;
                this.Promociones   = new DateTime[] {
                    DateTime.Parse("2019-01-01"),
                    DateTime.Parse("2019-02-10"),
                    DateTime.Parse("2019-03-20")
                };
                this.SelectedPromocion = this.Promociones.Last();
                this.Primero           = 123;
                this.Ultimo            = 456;

                //this.Total = 1234.5m;
                this.Pagar              = 100m;
                this.Search             = "123";
                this.Limite             = 1000;
                this.GenerateContraVale = true;
                this.Vale = new Common.Entities.ValeResponse
                {
                    Cancelado       = true,
                    CanceladoMotivo = "motivo",
                    Disponible      = 199m,
                    Vale            = "123",
                    ClienteId       = 1,
                    Vigencia        = DateTime.Parse("2020-01-15"),
                    Distribuidor    = new Common.Entities.Distribuidor
                    {
                        Id          = 1,
                        Nombre      = "nombre",
                        ApPaterno   = "appaterno",
                        ApMaterno   = "apmaterno",
                        Status      = Common.Constants.StatusDistribuidor.SOBREGIRADO,
                        Electronica = true,
                        Promocion   = true,
                        ContraVale  = true,
                        Firmas      = new short[] { 1, 2, 3 }
                    }
                };
            }
        }
コード例 #3
0
        public PagoValeViewModel()
        {
            this.Productos            = new ObservableCollection <Utilities.Models.ProductoPlazoOpciones>();
            this.ProductosView        = CollectionViewSource.GetDefaultView(this.Productos);
            this.ProductosView.Filter = i =>
            {
                var item = (Utilities.Models.ProductoPlazoOpciones)i;
                if (item.Item.FormasPago.Where(k => k.FormaPago == this.FormaPago).Any())
                {
                    return(true);
                }
                return(false);
            };
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.PlanPago = new ObservableCollection <Models.PlanPagoItem>();
            if (!IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.PropertyChanged += PagoValeViewModel_PropertyChanged;
            this.OpenFirma        = new RelayCommand <Models.FirmaIndex>(p =>
            {
                var ic  = new Converters.ImageUrlMultiConverter();
                var res = ic.Convert(new object[] { p.Id, p.Index }, typeof(string), "FirmaUrl", System.Globalization.CultureInfo.CurrentUICulture);
                //MessageBox.Show($"{p.Id}x{p.Index}");
                _image.OpenImage(res);
            });
            this.SearchCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy           = true;
                this.Vale             = await _proxy.FindValeAsync(this.Search);
                var pago              = (Models.Pagos.PagoVale) this.PagoIem;
                pago.Info.Electronica = true;
                if (this.Vale != null)
                {
                    pago.Info.Electronica = this.Vale.Distribuidor.Electronica;
                    this.Limite           = this.Vale.Limite;
                    this.Search           = null;
                    if (!this.HasPromocion)
                    {
                        this.SelectedPromocion = this.Promocion.Promociones.FirstOrDefault();
                    }
                    if (this.Vale.Distribuidor.Firmas != null && this.Vale.Distribuidor.Firmas.Any())
                    {
                        this.SelectedFirma = this.Vale.Distribuidor.Firmas.First();
                    }
                    else
                    {
                        this.SelectedFirma = null;
                    }
                    this.Caja.UpdatePagos();
                }
                else
                {
                    MessageBox.Show("El vale que ingresó no existe, por favor validelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.Search));

            if (!this.IsInDesignMode)
            {
                _image = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Interfaces.IImageView>();
                var settings = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>();
                this.Promocion = _proxy.FindPromocionesVale(settings.Sucursal.Clave);
                //if (promocion != null)
                //{
                //    //this.Plazos = promocion.Plazos;
                //    //this.SelectedPlazo = promocion.Selected;
                //    this.PagosMax = promocion.PagosMax;
                //    this.Promociones = promocion.Promociones;
                //    this.Fechas = promocion.Fechas;
                //    //this.SelectedPromocion = promocion.Promociones.Any() ? promocion.Promociones.Last() : (DateTime?)null;
                //}
            }

            if (this.IsInDesignMode)
            {
                this.HasPromocionPlazos = true;
                this.Plazos             = new int[] { 1, 2, 3 };
                this.SelectedPlazo      = 3;
                this.Promocion          = new PromocionesValeResponse
                {
                    Promociones = new DateTime[] {
                        DateTime.Parse("2019-01-01"),
                        DateTime.Parse("2019-02-10"),
                        DateTime.Parse("2019-03-20")
                    },
                    Fechas = new DateTime[] {
                        DateTime.Parse("2020-01-01"),
                        DateTime.Parse("2020-02-10"),
                        DateTime.Parse("2020-03-20")
                    },
                    Blindaje = 100
                };
                this.SelectedPromocion = this.Promocion.Promociones.Last();
                this.Primero           = 123;
                this.Ultimo            = 456;

                //this.Total = 1234.5m;
                this.Pagar              = 200m;
                this.Search             = "123";
                this.Limite             = 1000;
                this.GenerateContraVale = true;
                this.Vale = new Common.Entities.ValeResponse
                {
                    Cancelado       = true,
                    CanceladoMotivo = "motivo",
                    Disponible      = 199m,
                    Vale            = "123",
                    ClienteId       = 1,
                    Distribuidor    = new Common.Entities.Distribuidor
                    {
                        Id          = 1,
                        Cuenta      = "0123",
                        Nombre      = "nombre",
                        ApPaterno   = "appaterno",
                        ApMaterno   = "apmaterno",
                        Status      = Common.Constants.StatusDistribuidor.SOBREGIRADO,
                        Electronica = true,
                        Promocion   = true,
                        ContraVale  = true,
                        Firmas      = new short[] { 1, 2, 3 }
                    }
                };


                this.Productos.Add(new Utilities.Models.ProductoPlazoOpciones(new Models.Producto {
                    MaxPlazos = 30, Id = 1, Serie = "001", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, DescuentoDirecto = null, HasImage = true, Electronica = true
                }));
                this.Productos.Add(new Utilities.Models.ProductoPlazoOpciones(new Models.Producto {
                    MaxPlazos = 20, Id = 3, Serie = "003", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, DescuentoDirecto = 10
                }));

                this.PlanPago.Add(new Models.PlanPagoItem {
                    Number = 1, Date = DateTime.Parse("2019-01-01"), Amount = 110.99m
                });
                this.PlanPago.Add(new Models.PlanPagoItem {
                    Number = 2, Date = DateTime.Parse("2019-01-15"), Amount = 100.99m
                });
                this.PlanPago.Add(new Models.PlanPagoItem {
                    Number = 3, Date = DateTime.Parse("2019-02-01"), Amount = 90m
                });
            }
        }