コード例 #1
0
        public ConsultaDevolucionViewModel()
        {
            if (!this.IsInDesignMode)
            {
                _common  = new Helpers.CommonHelper();
                _proxy   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _reports = new Helpers.ReportsHelper();
            }
            this.PropertyChanged += ConsultaDevolucionViewModel_PropertyChanged;
            this.SearchCommand    = new RelayCommand(() => {
                var settings    = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>();
                var folio       = _common.PrepareVentaDevolucion(this.Search);
                this.Devolucion = _proxy.FindDevolucionView(settings.Sucursal.Clave, folio, this.Cajero.Id);
                if (this.Devolucion != null)
                {
                    this.Search = null;
                }
            });

            if (this.IsInDesignMode)
            {
                this.Search     = "devolucion";
                this.Devolucion = new Common.Entities.DevolucionView
                {
                    Folio     = "folio",
                    Sucursal  = "sucursal",
                    Productos = new Common.Entities.ProductoView[] {
                        new Common.Entities.ProductoView {
                            Serie = "1", Precio = 100
                        },
                        new Common.Entities.ProductoView {
                            Serie = "2", Precio = 99.9m
                        },
                        new Common.Entities.ProductoView {
                            Serie = "3", Precio = 1999.89m
                        }
                    }
                };
            }
        }
コード例 #2
0
        public CancelacionDevolucionViewModel()
        {
            if (!this.IsInDesignMode)
            {
                _data   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _client = new Helpers.ServiceClient();
            }
            _common            = new Helpers.CommonHelper();
            this.Productos     = new ObservableCollection <Models.CancelProducto>();
            this.CancelCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;

                var request = new Common.Entities.CancelSaleRequest
                {
                    Sucursal = this.Devolucion.Sucursal,
                    Folio    = this.Devolucion.Folio
                };
                await _client.CancelReturnAsync(request.Sucursal, request.Folio);

                this.Complete();
                MessageBox.Show("ready");
                this.CloseCommand.Execute(null);
                this.IsBusy = false;
            }, () => this.Productos.Any() && !this.Productos.Where(i => !i.Scanned).Any());
            this.SearchCommand = new RelayCommand(() =>
            {
                var ser  = _common.PrepareSerie(this.Search);
                var item = _data.ScanProductoFromDevolucion(ser);
                if (!this.Productos.Any())
                {
                    if (item != null && item.Success)
                    {
                        this.Search = null;
                        var dev     = _data.FindDevolucionView(item.Producto.Sucursal, item.Producto.Folio, this.Cajero.Id);

                        if (this.Sucursal.Clave != dev.Sucursal)
                        {
                            MessageBox.Show($"La devolución pertenece a otra sucursal ({dev.Sucursal})");
                            return;
                        }

                        this.Devolucion = new Models.SucursalFolio
                        {
                            Sucursal = dev.Sucursal,
                            Folio    = dev.Folio
                        };
                        foreach (var ditem in dev.Productos)
                        {
                            var can = new Models.CancelProducto
                            {
                                Producto = new Producto
                                {
                                    Id     = ditem.ArticuloId,
                                    Modelo = ditem.Modelo,
                                    Marca  = ditem.Marca,
                                    Precio = ditem.Precio,
                                    Serie  = ditem.Serie,
                                    Talla  = ditem.Medida
                                }
                            };
                            this.Productos.Add(can);
                            can.PropertyChanged += (s, e) => { this.CancelCommand.RaiseCanExecuteChanged(); };
                            if (can.Producto.Serie == ser)
                            {
                                can.Scanned = true;
                            }
                        }
                    }
                }
                else
                {
                    var pitem = this.Productos.Where(i => i.Producto.Serie == ser).SingleOrDefault();
                    if (pitem != null)
                    {
                        this.Search   = null;
                        pitem.Scanned = true;
                    }
                    else
                    {
                        this.ErrorMessage = Resources.Resource.Cancelacion_NoEncontrado;
                    }
                }
            }, () => !string.IsNullOrEmpty(this.Search));
            if (this.IsInDesignMode)
            {
                this.Search     = "0000003678429";
                this.Devolucion = new Models.SucursalFolio
                {
                    Sucursal = "00",
                    Folio    = "000123"
                };
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = true, Producto = new Producto {
                        Id = 1, Serie = "001", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 100, HasImage = true
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = true, Producto = new Producto {
                        Id = 2, Serie = "002", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1000, HasImage = true
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = false, Producto = new Producto {
                        Id = 3, Serie = "003", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1234.25m
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = true, Producto = new Producto {
                        Id = 4, Serie = "004", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 12456
                    }
                });
                this.Productos.Add(new Models.CancelProducto {
                    Scanned = false, Producto = new Producto {
                        Id = 5, Serie = "005", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 9.99m
                    }
                });
            }
        }