Пример #1
0
        //
        // GET: /Images/


        public ActionResult Index()
        {
            _commonHelper = new Helpers.CommonHelper();
            var lstImages = _commonHelper.GetUploadedImages();

            return(View(lstImages));
        }
Пример #2
0
        public PagoCreditoViewModel2()
        {
            if (!this.IsInDesignMode)
            {
                _common = new Helpers.CommonHelper();
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }

            this.PropertyChanged += PagoCreditoViewModel2_PropertyChanged;
            this.SearchCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy = true;
                var res     = _common.PrepareTarjetahabiente(this.Search);
                this.Vale   = await _proxy.FindTarjetahabienteAsync(res);
                if (this.Vale != null)
                {
                    this.Search = null;
                    if (!this.Vale.Distribuidor.Promocion)
                    {
                        this.SelectedPromocion = this.Promocion.Promociones.FirstOrDefault();
                    }
                }
                else
                {
                    MessageBox.Show("not found");
                }
                this.IsBusy = false;
            }, () => !String.IsNullOrEmpty(this.Search));
        }
Пример #3
0
        public ActionResult Upload()
        {
            var model = new ImageUploadViewModel();

            _commonHelper    = new Helpers.CommonHelper();
            model.ImageTypes = _commonHelper.GetImageTypes();
            _commonHelper    = null;
            return(View(model));
        }
Пример #4
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
                        }
                    }
                };
            }
        }
Пример #5
0
        public ActionResult Upload(ImageUploadViewModel model)
        {
            if (model.Images.Count() > 0)
            {
                _commonHelper    = new Helpers.CommonHelper();
                model.ImageTypes = _commonHelper.GetImageTypes();
                if (_commonHelper.UploadImages(model) > 0)
                {
                    Success("The image(s) upload completed successfully.", true);
                    return(View(model));
                }
                else
                {
                    Danger("The image(s) can not be uploaded.", true);
                }
            }
            else
            {
                Danger("Please select a file(s) to upload.", true);
            }

            return(View(model));
        }
Пример #6
0
        public CorteViewModel()
        {
            this.PropertyChanged += CorteViewModel_PropertyChanged;
            this.Items            = new ObservableCollection <Models.ItemCorte>();
            this.Series           = new ObservableCollection <Models.ItemCorteSerie>();
            _common = new Helpers.CommonHelper();
            if (!this.IsInDesignMode)
            {
                _proxy    = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>();
                _data     = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                this.Data = _proxy.GetCorteCaja(this.Sucursal.Clave, this.Cajero.Id);
                if (this.Data != null)
                {
                    this.Data.FormaPagoTotales.ToList().ForEach(i => {
                        var nitem = new Models.ItemCorte {
                            Item = i
                        };
                        nitem.PropertyChanged += Nitem_PropertyChanged;
                        this.Items.Add(nitem);
                    });
                    this.Data.Series.ToList().ForEach(i => this.Series.Add(new Models.ItemCorteSerie {
                        Item = i
                    }));
                }
            }

            this.LoadAuditorCommand = new RelayCommand(() =>
            {
                this.Auditor = _data.FindAuditorApertura(this.SearchAuditor.Value, this.Cajero.Id);
                if (this.Auditor != null)
                {
                    this.SearchAuditor = null;
                }
                else
                {
                    MessageBox.Show("Auditor no valido", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }, () => this.SearchAuditor.HasValue);
            //this.RemoveMontoCommand = new RelayCommand(() =>
            //{
            //    this.SelectedItemCorte.Detalle.Remove(this.SelectedDetalle);
            //}, () => this.SelectedItemCorte != null && this.SelectedDetalle != null);
            this.AddMontoCommand = new RelayCommand(() =>
            {
                this.SelectedItemCorte.Detalle.Add(new Models.ItemCorteDetalle {
                    Amount = this.MontoTicket
                });
                this.MontoTicket = null;
            }, () => this.SelectedItemCorte != null && this.MontoTicket.HasValue);
            this.ScanCommand = new RelayCommand(() =>
            {
                var ser  = _common.PrepareSerie(this.Scan);
                var item = this.Series.Where(i => i.Item.Serie == ser).SingleOrDefault();
                if (item != null)
                {
                    item.Reportado = true;
                    this.Scan      = null;
                }
                this.SaveCommand.RaiseCanExecuteChanged();
            }, () => !String.IsNullOrEmpty(this.Scan));
            this.SaveCommand = new RelayCommand(() =>
            {
                //var code = Microsoft.VisualBasic.Interaction.InputBox("Codigo Auditor:");
                //var isValid = _proxy.ValidarCodigo(this.Auditor.Id, code);
                //if (!isValid)
                //{
                //    MessageBox.Show("Código no valido", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                var request = new Common.Entities.CorteRequest
                {
                    Sucursal   = this.Sucursal.Clave,
                    CajeroId   = this.Cajero.Id,
                    AuditorId  = this.Auditor.Id,
                    FormasPago = this.Items.Select(i =>
                                                   new Common.Entities.ItemCorte {
                        FormaPago = i.Item.FormaPago,
                        Entregar  = i.Entrega.Value,
                        Amount    = i.Monto.Value
                    }),
                    Series   = this.Series.Where(i => i.Reportado).Select(i => i.Item.Serie),
                    Entregar = this.Entregar.Value
                };
                _proxy.Corte(request);
                MessageBox.Show("Corte generado exitosamente", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new Utilities.Messages.FondoAperturaCierre {
                    Open = false
                });
                this.CloseCommand.Execute(null);
            }, () => this.Auditor != null &&
                                                this.Entregar.HasValue &&
                                                (!this.Items.Any() || this.Items.All(i => i.Entrega.HasValue && i.Monto.HasValue)));

            this.CajeroFinger     = new RelayCommand(/*async*/ () => {
                //var fh = new Helpers.FingerPrintHelper();
                //if (fh.Connect())
                //{
                //    var finger = await fh.Scan();
                //    fh.Close();
                //    if (finger != null)
                //    {
                //        var huella = _proxy.GetHuella(this.Cajero.Id);
                //        if (huella != null)
                //        {
                //            this.CajeroValido = fh.Verify(finger, huella);
                //            this.SaveCommand.RaiseCanExecuteChanged();
                //        }
                //    }
                //}

                //this.CajeroValido = !this.CajeroValido;
            });
            this.SupervisorFinger = new RelayCommand(() => {
                //var fh = new Helpers.FingerPrintHelper();
                //if (fh.Connect())
                //{
                //    var finger = await fh.Scan();
                //    fh.Close();
                //    if (finger != null)
                //    {
                //        this.Auditor = _proxy.IdentificarSupervisor(this.Sucursal.Clave, finger);
                //        this.SupervisorValido = this.Auditor.HasValue;
                //        this.SaveCommand.RaiseCanExecuteChanged();
                //    }
                //}
                //if(this.Auditor != null)
                //    this.SupervisorValido = !this.SupervisorValido;
            });

            if (this.IsInDesignMode)
            {
                this.Scan = "scan";
                this.Data = new Common.Entities.CorteResponse
                {
                    FormaPagoTotales = new Common.Entities.FormaPagoCorte[] {
                        new Common.Entities.FormaPagoCorte {
                            FormaPago = Common.Constants.FormaPago.VA, Count = 4, Total = 600
                        },
                        new Common.Entities.FormaPagoCorte {
                            FormaPago = Common.Constants.FormaPago.TC, Count = 2, Total = 200
                        },
                        new Common.Entities.FormaPagoCorte {
                            FormaPago = Common.Constants.FormaPago.TD, Count = 3
                        },
                        new Common.Entities.FormaPagoCorte {
                            FormaPago = Common.Constants.FormaPago.DV, Count = 4
                        }
                    }, Series = new Common.Entities.SeriePrecio[] {
                        new Common.Entities.SeriePrecio {
                            Serie = "a", Importe = 1
                        },
                        new Common.Entities.SeriePrecio {
                            Serie = "b", Importe = 2
                        },
                        new Common.Entities.SeriePrecio {
                            Serie = "c", Importe = 3
                        }
                    },
                    Importe = 3000m
                              //Ventas = 100,
                              //Caja = 99
                };
                this.Entregar = 1600m;
                this.Data.FormaPagoTotales.ToList().ForEach(i => this.Items.Add(new Models.ItemCorte {
                    Item = i
                }));
                this.Items[1].Detalle.Add(new Models.ItemCorteDetalle {
                    Amount = 100
                });
                this.Items[1].Detalle.Add(new Models.ItemCorteDetalle {
                    Amount = 100
                });
                this.SelectedItemCorte = this.Items[0];
                this.SelectedItemCorte.Detalle.Add(new Models.ItemCorteDetalle {
                    Amount = 100
                });
                this.SelectedItemCorte.Detalle.Add(new Models.ItemCorteDetalle {
                    Amount = 200
                });
                this.SelectedItemCorte.Detalle.Add(new Models.ItemCorteDetalle {
                    Amount = 300
                });
                this.Data.Series.ToList().ForEach(i => this.Series.Add(new Models.ItemCorteSerie {
                    Item = i
                }));
                this.Series[2].Reportado = true;
                this.Auditor             = new Common.Entities.Empleado
                {
                    Nombre          = "nombre",
                    ApellidoPaterno = "appat",
                    ApellidoMaterno = "apmat"
                };
                this.MontoTicket = 199.99m;
            }
        }
Пример #7
0
        public DevolucionViewModel()
        {
            _common = new Helpers.CommonHelper();
            this.PropertyChanged             += DevolucionViewModel_PropertyChanged;
            this.Productos                    = new ObservableCollection <Models.ProductoDevolucion>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            if (!IsInDesignMode)
            {
                _reports = new Helpers.ReportsHelper();
                _client  = new Helpers.ServiceClient();
                _proxy   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.LoadCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;
                var ser     = _common.PrepareSerie(this.SerieSearch);

                var item = await _proxy.ScanProductoDevolucionAsync(ser, cancelacion: false);
                if (item != null && item.Success)
                {
                    if (!this.Productos.Any())
                    {
                        AddItem(item.Producto);
                        this.SerieSearch = null;
                        this.Venta       = new Models.SucursalFolio {
                            Sucursal = item.Producto.Sucursal, Folio = item.Producto.Folio
                        };

                        //var ven = _proxy.FindVentaView(this.Venta.Sucursal, this.Venta.Folio, 0);

                        var sale          = _proxy.FindSale(this.Venta.Sucursal, this.Venta.Folio);
                        this.CanSetClient = !sale.ClienteId.HasValue;
                        if (sale.ClienteId.HasValue)
                        {
                            this.Cliente = _proxy.FindCliente(sale.ClienteId.Value);
                            if (this.Cliente != null)
                            {
                                this.NuevoCliente = new Models.NuevoCliente
                                {
                                    Id        = this.Cliente.Id,
                                    Nombre    = this.Cliente.Nombre,
                                    ApPaterno = this.Cliente.ApPaterno,
                                    ApMaterno = this.Cliente.ApMaterno
                                };
                            }
                        }
                    }
                    else
                    {
                        if (this.Venta.Sucursal == item.Producto.Sucursal &&
                            this.Venta.Folio == item.Producto.Folio)
                        {
                            var current = this.Productos.Where(i => i.Item.Serie == item.Producto.Serie).SingleOrDefault();
                            if (current == null)
                            {
                                AddItem(item.Producto);
                            }
                            else
                            {
                                this.Productos.Remove(current);
                            }
                            this.SerieSearch = null;
                        }
                        else
                        {
                            MessageBox.Show($"El producto {item.Producto.Serie}, no pertenece a la misma venta.");
                        }
                    }
                }
                else
                {
                    if (item == null)
                    {
                        this.ErrorMessage = "Artículo no encontrado";
                    }
                    else
                    {
                        if (item.Status == Common.Constants.Status.BA)
                        {
                            this.ErrorMessage = "El articulo ha excedido el tiempo valido para su devolución o cambio";
                        }
                        else
                        {
                            this.ErrorMessage = "Artículo no valido";
                        }
                    }
                }
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.SerieSearch));
            this.ReturnCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                //Messenger.Default.Send(new Messages.RequestApproval { GID = this.GID });

                this.IsBusy = true;
                var request = new Common.Entities.ReturnRequest
                {
                    Sucursal = this.Venta.Sucursal,
                    Folio    = this.Venta.Folio,
                    Comments = "",
                    Items    = this.Productos.Select(i => i.Item.Serie),
                    Razones  = this.Productos.ToDictionary(i => i.Item.Serie,
                                                           i => new Common.Entities.RazonItem {
                        TipoRazon = i.RazonId.Value,
                        Notas     = i.Razon
                    })
                };
                request.Cliente = Helpers.Parsers.PaseCliente(this.NuevoCliente, this.Cliente, this.Sucursal);
                this.Folio      = await _client.ReturnAsync(request);
                this.IsBusy     = false;
            }, () => this.Total > 0);

            this.PrintCommand = new RelayCommand(() => {
                _reports.Devolucion(this.Sucursal.Clave, this.Folio);
            }, () => this.IsComplete);

            this.LoadClienteCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.cliente,
                    GID  = this.GID
                });
            }, () => this.CanSetClient);
            this.ClearClienteCommand = new RelayCommand(() =>
            {
                this.Cliente      = null;
                this.NuevoCliente = null;
            }, () => this.CanSetClient);
            if (this.IsInDesignMode)
            {
                this.ClienteId   = 90;
                this.Folio       = "123";
                this.SerieSearch = "0000003342601";
                this.Venta       = new Models.SucursalFolio {
                    Folio = "folio", Sucursal = "sucursal"
                };
                this.Productos.Add(new Models.ProductoDevolucion {
                    Item = new ProductoDevolucion {
                        Sucursal = "01", Folio = "123", Serie = "0000003413693", Marca = "FFF", Modelo = "2608", Talla = "27.5", Precio = 799
                    }
                });
                this.Productos.Add(new Models.ProductoDevolucion {
                    Item = new ProductoDevolucion {
                        Sucursal = "01", Folio = "124", Serie = "0000003420542", Marca = "AAA", Modelo = "1234", Talla = "28", Precio = 123.45m
                    }
                });

                this.NuevoCliente = new Client.Models.NuevoCliente {
                    Nombre = "nom", ApPaterno = "ap pa", ApMaterno = "ap ma"
                };
            }
        }
Пример #8
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
                    }
                });
            }
        }
Пример #9
0
        public CambioViewModel()
        {
            this.PropertyChanged += CambioViewModel_PropertyChanged;
            _common        = new Helpers.CommonHelper();
            this.Productos = new ObservableCollection <Models.ProductoCambio>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.Pagos.CollectionChanged     += Pagos_CollectionChanged;
            if (!this.IsInDesignMode)
            {
                _reports = new Helpers.ReportsHelper();
                _client  = new Helpers.ServiceClient();
                _proxy   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _mapper  = CommonServiceLocator.ServiceLocator.Current.GetInstance <AutoMapper.IMapper>();
            }

            //this.PagarCommand = new RelayCommand(() => {

            //    this.ShowPagos = true;

            //}, () => this.Total > 0 && this.Remaining > 0);
            //this.AddFormaCommand = new RelayCommand<FormaPago>(fp => {
            //    this.ShowPagos = false;
            //    Messenger.Default.Send(
            //        new Messages.OpenPago
            //        {
            //            GID = this.GID,
            //            FormaPago = fp,
            //            Total = this.Remaining,
            //            Caja = this,
            //            ClientId = this.Cliente?.Id,
            //            ProductosPlazos = this.Productos.Where(i => i.MaxPlazos.HasValue && i.MaxPlazos > 0)
            //        });
            //}, p => {
            //    var q = this._formas.Where(i => i.Key == p);
            //    return q.Any() && this.Total > 0 && this.Remaining > 0 && q.Single().Value.Enabled;
            //});
            this.AddPagoCommand = new RelayCommand(() => {
                this.ShowPagos = true;
            }, () => this.Remaining > 0);

            this.ScanCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;
                var ser     = _common.PrepareSerie(this.SerieSearch);

                await this.Scan(ser);
                this.AddPagoCommand.RaiseCanExecuteChanged();
                this.SaveCommand.RaiseCanExecuteChanged();

                this.IsBusy = false;
            }, () => !string.IsNullOrEmpty(this.SerieSearch));

            this.SaveCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;
                var request = new Common.Entities.ChangeRequest
                {
                    Sucursal = this.Venta.Sucursal,
                    Folio    = this.Venta.Folio,
                    Items    = this.Productos.Select(i => new Common.Entities.ChangeItem
                    {
                        OldItem = i.OldItem.Serie,
                        NewItem = i.NewItem.Serie
                    }),
                    Pagos   = this.PreparePagos(),
                    Razones = this.Productos.ToDictionary(i => i.OldItem.Serie,
                                                          i => new Common.Entities.RazonItem
                    {
                        TipoRazon = i.RazonId.Value,
                        Notas     = i.Razon
                    })
                };
                request.Cliente = Helpers.Parsers.PaseCliente(this.NuevoCliente, this.Cliente, this.Sucursal);
                this.Result     = await _client.ChangeAsync(request);
                this.IsBusy     = false;
            }, () => this.Productos.Any() &&
                                                                           !this.Productos.Where(i => !i.Complete).Any() &&
                                                                           this.Remaining <= 0);

            this.RemovePagoCommand = new RelayCommand(() => {
                //if (!_formas[this.SelectedPago.FormaPago].Duplicate)
                //{
                //    _formas[this.SelectedPago.FormaPago].Enabled = true;
                //    this.FormasPago.Refresh();
                //}
                //_ls.RemovePago(this.SelectedPago.Id);
                this.Pagos.Remove(this.SelectedPago);
            }, () => this.SelectedPago != null);

            this.LoadClienteCommand = new RelayCommand(() => {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.cliente,
                    GID  = this.GID
                });
            });
            this.ClearClienteCommand = new RelayCommand(() => {
                this.Cliente      = null;
                this.NuevoCliente = null;
                foreach (var item in this.Pagos.Where(i => i.ClientId.HasValue).ToArray())
                {
                    this.Pagos.Remove(item);
                    //_ls.RemovePago(item.Id);
                }
                this.ClientConfirmed = false;
                this.FormasPago.Refresh();
            });

            this.PrintCommand = new RelayCommand <string>(rpt => {
                if (rpt == "venta")
                {
                    _reports.Compra(this.Sucursal.Clave, this.Result.Venta);
                }
                if (rpt == "devolucion")
                {
                    _reports.Devolucion(this.Sucursal.Clave, this.Result.Devolucion);
                }
            }, rpt => this.IsComplete);

            if (this.IsInDesignMode)
            {
                this.Result = new ChangeResponse {
                    Devolucion = "111",
                    Venta      = "222",
                    Cliente    = 333
                };
                this.SerieSearch = "0000003342601";
                this.Venta       = new Models.SucursalFolio {
                    Sucursal = "01", Folio = "000123"
                };
                this.Productos.Add(new Models.ProductoCambio {
                    OldItem = new ProductoDevolucion {
                        Sucursal = "01", Folio = "123", Serie = "0000003413693", Marca = "FFF", Modelo = "2608", Talla = "27.5", Precio = 799
                    },
                    NewItem = new Models.Producto {
                        Serie = "0000003420542", Marca = "AAA", Modelo = "1234", Talla = "28", Precio = 123.45m
                    }
                });
                this.Productos.Add(new Models.ProductoCambio
                {
                    OldItem = null,
                    NewItem = new Models.Producto {
                        Serie = "0000003420542", Marca = "AAA", Modelo = "1234", Talla = "28", Precio = 123.45m
                    }
                });
                this.Productos.Add(new Models.ProductoCambio
                {
                    OldItem = new ProductoDevolucion {
                        Sucursal = "01", Folio = "123", Serie = "0000003413693", Marca = "FFF", Modelo = "2608", Talla = "27.5", Precio = 799
                    },
                    NewItem = null
                });
                this.NuevoCliente = new Models.NuevoCliente {
                    Nombre = "nom", ApPaterno = "ap pa", ApMaterno = "ap ma"
                };
            }
        }
Пример #10
0
        public LoadClienteViewModel()
        {
            if (!this.IsInDesignMode)
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }

            _common                = new Helpers.CommonHelper();
            this.Screen            = "search";
            this.ChangeViewCommand = new RelayCommand <string>(v => {
                this.Screen = v;
            });

            this.PropertyChanged += LoadClienteViewModel_PropertyChanged;

            this.SearchCommand = new RelayCommand(() => {
                if (!this.ClienteSearch.HasValue && string.IsNullOrWhiteSpace(this.ClienteTelefonoSearch))
                {
                    if (this.Cliente != null)
                    {
                        Messenger.Default.Send(new Messages.ClienteMessage
                        {
                            Cliente = this.Cliente
                        }, this.GID);
                    }
                }
                else
                {
                    var phone    = _common.PreparePhone(this.ClienteTelefonoSearch);
                    this.Cliente = _proxy.FindCliente(this.ClienteSearch, phone);
                    if (this.Cliente != null)
                    {
                        this.ClienteSearch         = null;
                        this.ClienteTelefonoSearch = null;
                    }
                    else
                    {
                        MessageBox.Show("Cliente no encontrado.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            });

            if (this.IsInDesignMode)
            {
                this.ClienteSearch         = 123;
                this.ClienteTelefonoSearch = "1234567890";
                this.NuevoCliente          = new Models.NuevoCliente
                {
                    Nombre       = "nombre",
                    ApPaterno    = "ap paterno",
                    ApMaterno    = "ap materno",
                    Calle        = "calle",
                    Celular      = "1234567890",
                    CodigoPostal = "cp",
                    Colonia      = null,
                    Email        = "email",
                    Referencia   = "entre calles",
                    Numero       = 123,
                };

                this.Colonias = new Common.Entities.Colonia[] {
                    new Common.Entities.Colonia
                    {
                        Id           = 1,
                        Nombre       = "colonia",
                        CodigoPostal = "cp",
                        CiudadId     = 2,
                        CiudadNombre = "ciudad",
                        EstadoId     = 3,
                        EstadoNombre = "estado"
                    }
                };
                this.NuevoCliente.Colonia = this.Colonias.First();
            }
        }
Пример #11
0
        public CajaViewModel()
        {
            _skipPromociones = false;
            _common          = new Helpers.CommonHelper();
            this.Productos   = new ObservableCollection <Models.Producto>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.Cupones            = new ObservableCollection <Cupon>();
            this.PromocionesCupones = new ObservableCollection <Promocion>();
            this.PromocionesCupones.CollectionChanged += PromocionesCupones_CollectionChanged;
            _promocionesCuponesUsadas = new CollectionViewSource {
                Source = this.PromocionesCupones
            };
            this.PromocionesCuponesUsadas.Filter = i => {
                var item = (Promocion)i;
                return(item.Used);
            };
            this.Pagos.CollectionChanged += Pagos_CollectionChanged;
            this.PropertyChanged         += CajaViewModel_PropertyChanged;

            if (!IsInDesignMode)
            {
                _reports = new Helpers.ReportsHelper();
                _proxy   = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _pproxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.ICommonServiceAsync>();
                _mapper  = CommonServiceLocator.ServiceLocator.Current.GetInstance <AutoMapper.IMapper>();
                _client  = new Helpers.ServiceClient();
            }

            this.RemovePagoCommand = new RelayCommand(/*async */ () => {
                //_ls.RemovePago(this.SelectedPago.Id);
                this.Pagos.Remove(this.SelectedPago);
                //await this.UpdatePromociones();
            }, () => this.SelectedPago != null);

            this.RemoveCuponCommand = new RelayCommand(() => {
                var cupon = this.SelectedCupon;
                //_ls.RemoveCupon(cupon.Folio);
                var q = this.PromocionesCupones.OfType <PromocionCupon>().Where(i => i.Cupon == cupon.Folio).ToArray();
                foreach (var item in q)
                {
                    this.PromocionesCupones.Remove(item);
                }
                this.Cupones.Remove(this.SelectedCupon);
            }, () => this.SelectedCupon != null);

            this.SaleCommand = new RelayCommand(this.Sale, () => {
                if (this.SaleResponse == null &&
                    this.Total > 0 && this.Remaining == 0)
                {
                    if (this.IsValid())
                    {
                        var pagado = this.Productos.All(i => i.Pagado);
                        if (pagado)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            });

            this.RemoveCommand = new RelayCommand(async() =>
            {
                await this.RemoveItem(this.SelectedItem);
            }, () => this.SelectedItem != null);
            this.AddCommand = new RelayCommand(async() => {
                //this.IsBusy = true;
                await Add();
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.SerieSearch));

            this.AddCuponCommand = new RelayCommand(() => {
                this.IsBusy = true;
                this.AddCuponHelper();
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.CuponSearch));

            this.LoadClienteCommand = new RelayCommand(() => {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.cliente,
                    GID  = this.GID
                });
            });
            this.LoadVendedorCommand = new RelayCommand(() => {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModal
                {
                    Name = Utilities.Constants.Modals.vendedor,
                    GID  = this.GID
                });
            }, () => this.HasCalzado);
            this.RemoveVendedorCommand = new RelayCommand(() =>
            {
                this.Vendedor = null;
            }, () => this.Vendedor != null);
            this.AddDescuentoAdicional = new RelayCommand(() => {
                if (this.SelectedItem.DescuentoAdicional != null)
                {
                    this.SelectedItem.DescuentoAdicional = null;
                }
                else
                {
                    Messenger.Default.Send(
                        new Utilities.Messages.OpenModal
                    {
                        Name = Utilities.Constants.Modals.descuento,
                        GID  = this.GID
                    });
                }
            }, () => this.SelectedItem != null);
            this.AddNotaCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(
                    new Utilities.Messages.OpenModalItem
                {
                    Name = Utilities.Constants.Modals.nota,
                    GID  = this.GID,
                    Item = this.SelectedItem
                });
            }, () => this.SelectedItem != null);
            this.ClearClienteCommand = new RelayCommand(async() => {
                this.Cliente      = null;
                this.NuevoCliente = null;
                _ls.ClearCliente();
                _skipPromociones = true;
                foreach (var item in this.PromocionesCupones.OfType <Common.Entities.PromocionCupon>().ToArray())
                {
                    if (item.Cliente.HasValue)
                    {
                        this.PromocionesCupones.Remove(item);
                        _ls.RemoveCupon(item.Cupon);
                    }
                }
                foreach (var item in this.Pagos.Where(i => i.ClientId.HasValue).ToArray())
                {
                    this.Pagos.Remove(item);
                    //_ls.RemovePago(item.Id);
                }
                this.ClientConfirmed = false;
                this.FormasPago.Refresh();
                _skipPromociones = false;
                await this.RefreshPromociones();
                this.SaleCommand.RaiseCanExecuteChanged();
            });

            MoveProductoCommand = new RelayCommand <Models.MoveDirection>(async dir => {
                this.Move(this.SelectedItem, this.Productos, dir, o => this.SelectedItem = o);
                await this.RefreshPromociones();
            }, dir => this.CanMove(this.SelectedItem, this.Productos, dir));

            MovePagoCommand = new RelayCommand <Models.MoveDirection>(async dir => {
                this.Move(this.SelectedPago, this.Pagos, dir, o => this.SelectedPago = (Models.Pagos.Pago)o);
                await this.RefreshPromociones();
            }, dir => this.CanMove(this.SelectedPago, this.Pagos, dir));

            MoveCuponCommand = new RelayCommand <Models.MoveDirection>(async dir => {
                this.Move(this.SelectedPromocion, this.PromocionesCupones, dir, o => this.SelectedPromocion = o);
                await this.RefreshPromociones();
            }, dir => this.CanMove(this.SelectedPromocion, this.PromocionesCupones, dir));

            this.PagarCommand = new RelayCommand(() => {
                this.ShowPagos = true;
            }, () => this.Total > 0 && this.Remaining > 0);


            this.ConfirmClienteCommand = new RelayCommand(() => {
            });

            if (!this.IsInDesignMode)
            {
                _scanner = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Interfaces.IScanner>();
                if (_scanner != null)
                {
                    _scanner.DataReceived += Scaner_DataReceived;
                }
            }

            this.PrintCommand = new RelayCommand(() => {
                _reports.Compra(this.Sucursal.Clave, this.SaleResponse.Folio);
            }, () => this.IsComplete);

            this.TestCommand = new RelayCommand <string>(p => {
                if (p == "start")
                {
                    _scanner?.Start();
                }
                if (p == "stop")
                {
                    _scanner?.Stop();
                }
            });
        }
Пример #12
0
        public PuntoDeVentaViewModel()
        {
            if (!IsInDesignMode)
            {
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _pproxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.ICommonServiceAsync>();
            }
            this.Productos = new ObservableCollection <Producto>();
            this.Pagos     = new ObservableCollection <Models.Pagos.Pago>();
            _formas        = new Dictionary <FormaPago, bool> {
                { FormaPago.EF, true },
                { FormaPago.TC, true },
                { FormaPago.TD, true }
            };
            this.FormasPago        = CollectionViewSource.GetDefaultView(_formas);
            this.FormasPago.Filter = i => ((KeyValuePair <FormaPago, bool>)i).Value;
            this.ShowSerie         = true;
            _common = new Helpers.CommonHelper();

            this.SaleCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                var sale = new SaleRequest {
                    VendedorId = 0,
                    Productos  = this.Productos.Select(i => new SerieFormasPago {
                        Serie = i.Serie
                    }),
                    Sucursal = "01",
                    Pagos    = this.Pagos.Where(i => (i.Importe ?? 0) > 0).Select(i => new Common.Entities.Pago {
                        FormaPago = i.FormaPago,
                        Importe   = i.Importe.Value
                    })
                };
                //var res = await _proxy.SaleAsync(sale);
                //MessageBox.Show($"ID: {res}");
            }, () => {
                var sum = this.Pagos.Sum(i => i.Importe) ?? 0;
                var rem = this.Total - sum;
                return(this.Total > 0 && rem == 0);
            });
            this.AddFormaCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() => {
                var p = new Models.Pagos.Pago {
                    FormaPago = this.SelectedFormaPago
                };
                this.Pagos.Add(p);
                p.PropertyChanged += (s, e) => RaisePropertyChanged(nameof(this.TotalPayment));
                if (this.SelectedFormaPago == FormaPago.EF)
                {
                    _formas[FormaPago.EF] = false;
                    this.FormasPago.Refresh();
                }
            });
            this.FindVendedorCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.Vendedor = await _pproxy.FindVendedorAsync(this.VendedorSearch.Value);
                if (this.Vendedor != null)
                {
                    this.VendedorSearch = null;
                }
            });
            this.FindCajeroCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.Cajero = await _pproxy.FindCajeroAsync(this.CajeroSearch);
                if (this.Cajero != null)
                {
                    this.CajeroSearch = null;
                }
            });

            this.AddCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy = true;
                var ser     = _common.PrepareSerie(this.Serie);

                var q = this.Productos.Where(i => i.Serie == ser).SingleOrDefault();
                if (q != null)
                {
                    MessageBox.Show($"Already Added: {ser}");
                    return;
                }

                var item = await _proxy.ScanProductoAsync(ser, "01");
                if (item != null)
                {
                    if (item.Status == Status.AC || item.Status == Status.IF ||
                        item.Status == Status.CA)
                    {
                        //if(await _proxy.RequestProductoAsync(item.Producto.Serie))
                        //    this.Productos.Add(item.Producto);
                    }
                    else
                    {
                        MessageBox.Show($"{item.Producto.Serie} - {item.Status}");
                    }
                    this.Serie = null;
                }
                else
                {
                    MessageBox.Show($"Not Found: {ser}");
                }
                this.IsBusy = false;
            }, () =>
            {
                return(!string.IsNullOrWhiteSpace(this.Serie));
            });
            this.RemoveCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                //await _proxy.ReleaseProductoAsync(this.SelectedItem.Serie);
                //this.Productos.Remove(this.SelectedItem);
            }, () =>
            {
                return(this.SelectedItem != null);
            });

            this.PropertyChanged             += PuntoDeVenta_PropertyChanged;
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.Pagos.CollectionChanged     += Pagos_CollectionChanged;

            if (this.IsInDesignMode)
            {
                this.Serie = "123";
                this.Productos.Add(new Producto {
                    Id = 1, Serie = "001", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 100, HasImage = true
                });
                this.Productos.Add(new Producto {
                    Id = 2, Serie = "002", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1000, HasImage = true
                });
                this.Productos.Add(new Producto {
                    Id = 3, Serie = "003", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 1234.25m
                });
                this.Productos.Add(new Producto {
                    Id = 4, Serie = "004", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 12456
                });
                this.Productos.Add(new Producto {
                    Id = 5, Serie = "005", Marca = "a", Modelo = "b", Talla = "c", Precio = 100, Total = 9.99m
                });

                this.Pagos.Add(new Models.Pagos.Pago {
                    FormaPago = FormaPago.EF, Importe = 100
                });
                this.Pagos.Add(new Models.Pagos.Pago {
                    FormaPago = FormaPago.TD, Importe = 30
                });
                this.Pagos.Add(new Models.Pagos.Pago {
                    FormaPago = FormaPago.TD, Importe = 20
                });
            }
        }
Пример #13
0
        public PagoCreditoViewModel()
        {
            if (!IsInDesignMode)
            {
                _common = new Helpers.CommonHelper();
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
            this.PropertyChanged += PagoValeViewModel_PropertyChanged;
            this.SearchCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                this.IsBusy          = true;
                this.Tarjetahabiente = await this.Find(this.Search);
                if (this.Tarjetahabiente != null)
                {
                    this.Search = null;
                    if (!this.Tarjetahabiente.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.Tarjetahabiente    = 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 }
                };
            }
        }
Пример #14
0
        public MainViewModel()
        {
            this.PropertyChanged             += MainViewModel_PropertyChanged;
            this.Productos                    = new ObservableCollection <Models.ProductoItem>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;
            this.AddCommand                   = new Command(() =>
            {
                var com  = new Helpers.CommonHelper();
                var ser  = com.PrepareSerie(this.Serie);
                var item = _proxy.ScanProducto(ser, this.Sucursal);
                if (item != null)
                {
                    this.Serie = null;
                    this.Productos.Add(new Models.ProductoItem {
                        Item = new Models.Producto
                        {
                            Id    = item.Id,
                            Serie = item.Serie,
                            //public string Marca { get; set; }
                            //public string Modelo { get; set; }
                            Precio   = item.Precio,
                            HasImage = item.HasImage
                        }
                    });
                }
                //this.ImageUrl = String.Format($"{Constants.Parameters.ServiceUrl}/Images/Producto?marca={0}&modelo={1}", "CTA", 83);
            }, () => !String.IsNullOrEmpty(this.Serie));

            this.SaleCommand = new Command(() => {
                var request = new SirCoPOS.Contracts.Entities.SaleRequest
                {
                    Sucursal = this.Sucursal,
                    Pagar    = this.Pagar,
                    Series   = this.Productos.Select(i => i.Item.Serie)
                };
                var res = _proxy.Sale(request);
                if (res != null)
                {
                    MessagingCenter.Send(new Messages.Alert {
                        Message = $"Folio: {res.Folio}"
                    }, "");
                }
                else
                {
                    MessagingCenter.Send(new Messages.Alert {
                        Message = "error"
                    }, "");
                }

                this.Productos.Clear();
                this.Pagar = null;
            }, () => (this.Total ?? 0) > 0 && this.Pagar == this.Total);

            if (this.IsInDesignMode)
            {
                this.Productos.Add(new Models.ProductoItem {
                    Item = new Models.Producto {
                        Serie = "123"
                    }
                });
                this.Productos.Add(new Models.ProductoItem {
                    Item = new Models.Producto {
                        Serie = "456"
                    }
                });
                this.Productos.Add(new Models.ProductoItem {
                    Item = new Models.Producto {
                        Serie = "789"
                    }
                });
            }

            if (!this.IsInDesignMode)
            {
                var myBinding  = new BasicHttpBinding();
                var myEndpoint = new EndpointAddress($"{Constants.Parameters.ServiceUrl}/Service.svc");
                _proxy = new System.ServiceModel.ChannelFactory <Contracts.Services.IService>(myBinding, myEndpoint).CreateChannel();
            }
        }
Пример #15
0
        public ConsultaProductoViewModel()
        {
            _common            = new Helpers.CommonHelper();
            this.SearchCommand = new RelayCommand(async() =>
            {
                this.IsBusy = true;
                await this.Search();
                this.IsBusy = false;
            }, () => {
                if (string.IsNullOrEmpty(this.Serie))
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(this.Marca) && string.IsNullOrEmpty(this.Modelo))
                {
                    return(true);
                }
                return(false);
            });
            this.FindMedidaCommand = new RelayCommand(async() =>
            {
                this.IsBusy      = true;
                this.Existencias = await _proxy.GetExistenciasAsync(this.Item.Id.Value, this.SelectedMedida);
                this.IsBusy      = false;
            }, () => this.Item != null && this.SelectedMedida != null);

            this.PropertyChanged += ConsultaProductoViewModel_PropertyChanged;
            if (this.IsInDesignMode)
            {
                this.Serie  = "0000003806584";
                this.Marca  = "ADD";
                this.Modelo = "1197";
                this.Item   = new Common.Entities.Producto
                {
                    Serie       = "0000003806584",
                    Marca       = "ADD",
                    Modelo      = "1197",
                    Talla       = "28.5",
                    Precio      = 1799.99m,
                    Corrida     = "A",
                    Electronica = false,
                    ParUnico    = true,
                    MaxPlazos   = 10,
                    Sucursal    = "08"
                };
                this.Corridas = new Common.Entities.MedidasCorridas
                {
                    Corridas = new Common.Entities.TallaPrecio[] {
                        new Common.Entities.TallaPrecio {
                            Corrida = "A", MedidaFin = "14-", MedidaInicio = "29-", Precio = 1099.99m
                        },
                        new Common.Entities.TallaPrecio {
                            Corrida = "B", MedidaFin = "24", MedidaInicio = "29-", Precio = 999m
                        },
                        new Common.Entities.TallaPrecio {
                            Corrida = "C", MedidaFin = "30", MedidaInicio = "39", Precio = 1234.56m
                        }
                    },
                    Medidas = new string[] { "20", "20-", "24-" }
                };
                this.SelectedMedida = "24-";
                this.Existencias    = new Common.Entities.SucursalExistencia[]
                {
                    //new Common.Entities.SucursalExistencia { Sucursal = "08", Count = 10 },
                    //new Common.Entities.SucursalExistencia { Sucursal = "01", Count = 30 },
                    //new Common.Entities.SucursalExistencia { Sucursal = "04", Count = 5 }
                };

                this.ItemStatus = Common.Constants.Status.CA;
                this.Promos     = new Common.Entities.Promocion[] {
                    new Common.Entities.Promocion {
                        PromocionId = 1, Nombre = "promo 1"
                    },
                    new Common.Entities.Promocion {
                        PromocionId = 1, Nombre = "promo 2"
                    },
                    new Common.Entities.Promocion {
                        PromocionId = 1, Nombre = "promo 3"
                    }
                };
            }
            else
            {
                _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
            }
        }
Пример #16
0
        public CancelacionViewModel()
        {
            if (!IsInDesignMode)
            {
                _proxy  = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _client = new Helpers.ServiceClient();
            }
            _common = new Helpers.CommonHelper();
            this.PropertyChanged             += CancelacionViewModel_PropertyChanged;
            this.Productos                    = new ObservableCollection <Models.CancelProducto>();
            this.Productos.CollectionChanged += Productos_CollectionChanged;

            this.ScanCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;
                await Scan();
                this.IsBusy = false;
            }, () => !string.IsNullOrWhiteSpace(this.SerieSearch));

            this.CancelCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() => {
                this.IsBusy = true;

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

                this.Complete();

                this.IsBusy = false;
            }, () => this.Productos.Any() && !this.Productos.Where(i => !i.Scanned).Any());

            if (this.IsInDesignMode)
            {
                this.ErrorMessage = "error";
                this.Venta        = new Models.SucursalFolio {
                    Sucursal = "01", Folio = "414628"
                };
                this.SerieSearch = "0000003343805";
                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
                    }
                });
            }
        }