public FondoCierreViewModel() { this.SaveCommand = new RelayCommand(() => { var request = new Common.Entities.FondoArqueoRequest { Importe = this.Importe.Value, Auditor = this.Auditor.Value, Responsable = this.Responsable.Value }; _proxy.CierreFondo(request); MessageBox.Show("ready"); GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new Utilities.Messages.FondoAperturaCierre { Open = false }); }); if (this.IsInDesignMode) { this.Responsable = 1; this.Auditor = 2; this.Importe = 100; } else { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); this.Responsable = this.Cajero.Id; } }
public FondoArqueoViewModel() { this.PropertyChanged += FondoArqueoViewModel_PropertyChanged; 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.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.FondoArqueoRequest { Importe = this.Importe.Value, Auditor = this.Auditor.Id, Responsable = this.Cajero.Id }; _proxy.ArqueoFondo(request); MessageBox.Show("ready"); this.CloseCommand.Execute(null); }, () => this.Auditor != null && this.Importe.HasValue && this.Effectivo.HasValue && this.Faltante >= 0); if (this.IsInDesignMode) { this.Effectivo = 150; this.Auditor = new Common.Entities.Empleado { Nombre = "nom", ApellidoMaterno = "mat", ApellidoPaterno = "pat" }; this.Importe = 100; this.SearchAuditor = 99; } else { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); _data = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>(); this.Effectivo = _proxy.GetDisponibleFondo(this.Cajero.Id); } }
public BonosViewModel() { this.PropertyChanged += BonosViewModel_PropertyChanged; this.Items = new ObservableCollection <Common.Entities.BonoDetalle>(); if (!this.IsInDesignMode) { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); } this.SaveCommand = new RelayCommand(() => { _proxy.PayBono( gerente: this.Gerente.Value, empleado: Empleado.Value, importe: this.TotalRound.Value); MessageBox.Show("ready"); }, () => this.Gerente.HasValue); this.LoadCommand = new RelayCommand(() => { var res = _proxy.GetBonos(this.Empleado.Value); this.Items.Clear(); res.Detalle.ToList().ForEach(i => this.Items.Add(i)); this.RaisePropertyChanged(nameof(this.Total)); }, () => this.Empleado.HasValue); if (this.IsInDesignMode) { this.Items.Add(new Common.Entities.BonoDetalle { Unidades = 1, Descripcion = "a", Importe = 99 }); this.Items.Add(new Common.Entities.BonoDetalle { Unidades = 2, Descripcion = "b", Importe = 100 }); this.Items.Add(new Common.Entities.BonoDetalle { Unidades = 3, Descripcion = "c", Importe = 199 }); } }
public FondoTransferirViewModel() { this.SaveCommand = new RelayCommand(() => { var request = new Common.Entities.FondoTransferRequest { Importe = this.Importe.Value, UserFrom = this.UserFrom.Value, UserTo = this.UserTo.Value }; _proxy.TransferirFondo(request); MessageBox.Show("ready"); }); if (this.IsInDesignMode) { UserFrom = 2; UserTo = 3; Importe = 100; } else { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); } }
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; } }
public FondoAperturaViewModel() { this.PropertyChanged += FondoAperturaViewModel_PropertyChanged; 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.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.FondoRequest { Importe = this.Importe.Value, Auditor = this.Auditor.Id, Responsable = this.Cajero.Id, Sucursal = this.Sucursal.Clave, Numero = this.SelectedCaja.Numero, Tipo = (Common.Constants.TipoFondo) this.SelectedCaja.Tipo }; _proxy.AbrirFondo(request); MessageBox.Show("La operación se completó correctamente", "Aviso", MessageBoxButton.OK, MessageBoxImage.Information); GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new Utilities.Messages.FondoAperturaCierre { Open = true }); this.CloseCommand.Execute(null); }, () => this.Auditor != null && this.Importe.HasValue && this.SelectedCaja != null && this.IsValid()); if (this.IsInDesignMode) { this.Auditor = new Common.Entities.Empleado { Nombre = "nombre", ApellidoPaterno = "appat", ApellidoMaterno = "apmat" }; this.SearchAuditor = 2; this.Importe = 100; this.Cajas = new Common.Entities.Caja[] { new Common.Entities.Caja { Tipo = 1, Numero = 1, Importe = 1000m }, new Common.Entities.Caja { Tipo = 0, Numero = 2 }, new Common.Entities.Caja { Tipo = 1, Numero = 3 } }; this.SelectedCaja = this.Cajas.First(); } else { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); _data = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>(); this.Cajas = _proxy.GetCajas(this.Sucursal.Clave, this.Cajero.Id); } }
public MenuViewModel() { _options = new Dictionary <Utilities.Constants.TabType, bool>() { { Utilities.Constants.TabType.Caja, true } , { Utilities.Constants.TabType.Nota, true } , { Utilities.Constants.TabType.NotaRevision, true } , { Utilities.Constants.TabType.CreditoPersonal, true } , { Utilities.Constants.TabType.VerificarVale, true } , { Utilities.Constants.TabType.VerificarValeExterno, true } , { Utilities.Constants.TabType.DineroElectronico, true } , { Utilities.Constants.TabType.Administracion, true } , { Utilities.Constants.TabType.Cambio, true } , { Utilities.Constants.TabType.Devolucion, true } , { Utilities.Constants.TabType.Cancelacion, true } , { Utilities.Constants.TabType.CancelacionDevolucion, true } , { Utilities.Constants.TabType.CancelacionCambio, true } , { Utilities.Constants.TabType.ConsultaVenta, true } , { Utilities.Constants.TabType.ConsultaDevolucion, true } , { Utilities.Constants.TabType.ConsultaProducto, true } , { Utilities.Constants.TabType.Pagos, true } , { Utilities.Constants.TabType.Corte, true } , { Utilities.Constants.TabType.Efectivo, true } , { Utilities.Constants.TabType.FondoApertura, true } , { Utilities.Constants.TabType.FondoCierre, true } , { Utilities.Constants.TabType.FondoArqueo, true } , { Utilities.Constants.TabType.FondoTransferir, true } , { Utilities.Constants.TabType.CambiarResponsable, true } , { Utilities.Constants.TabType.Gasto, true } , { Utilities.Constants.TabType.Bonos, true } }; this.OpenCommand = new RelayCommand <Utilities.Constants.TabType>( m => { GalaSoft.MvvmLight.Messaging.Messenger.Default.Send( new Messages.MenuItem { Name = m }); }, m => _options.ContainsKey(m) && _options[m] ); this.CloseCommand = new RelayCommand(() => { System.Windows.Application.Current.Shutdown(); }); this.LogoutCommand = new RelayCommand(() => { GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new Utilities.Messages.LogoutTimeout()); //var ls = new Helpers.LocalStorage(); //ls.ClearCajero(); }); GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <Utilities.Messages.FondoAperturaCierre>(this, m => { foreach (var key in _options.Keys.ToArray()) { _options[key] = m.Open; } //_options[Utilities.Constants.TabType.Caja] = !m.Open; //_options[Utilities.Constants.TabType.Nota] = !m.Open; //_options[Utilities.Constants.TabType.NotaRevision] = !m.Open; //_options[Utilities.Constants.TabType.CreditoPersonal] = !m.Open; //_options[Utilities.Constants.TabType.VerificarVale] = !m.Open; //_options[Utilities.Constants.TabType.VerificarValeExterno] = !m.Open; //_options[Utilities.Constants.TabType.DineroElectronico] = !m.Open; //_options[Utilities.Constants.TabType.FondoApertura] = !m.Open; //_options[Utilities.Constants.TabType.Cambio] = !m.Open; //_options[Utilities.Constants.TabType.Devolucion] = !m.Open; //_options[Utilities.Constants.TabType.Cancelacion] = !m.Open; //_options[Utilities.Constants.TabType.CancelacionDevolucion] = !m.Open; //_options[Utilities.Constants.TabType.CancelacionCambio] = !m.Open; //_options[Utilities.Constants.TabType.ConsultaVenta] = !m.Open; //_options[Utilities.Constants.TabType.ConsultaDevolucion] = !m.Open; //_options[Utilities.Constants.TabType.ConsultaProducto] = !m.Open; //_options[Utilities.Constants.TabType.Pagos] = !m.Open; //_options[Utilities.Constants.TabType.Corte] = !m.Open; //_options[Utilities.Constants.TabType.Efectivo] = !m.Open; _options[Utilities.Constants.TabType.FondoApertura] = !m.Open; //_options[Utilities.Constants.TabType.FondoCierre] = !m.Open; //_options[Utilities.Constants.TabType.FondoArqueo] = !m.Open; //_options[Utilities.Constants.TabType.FondoTransferir] = !m.Open; //_options[Utilities.Constants.TabType.CambiarResponsable] = !m.Open; //_options[Utilities.Constants.TabType.Gasto] = !m.Open; //_options[Utilities.Constants.TabType.Bonos] = !m.Open; //_options[Utilities.Constants.TabType.Credit] = !m.Open; this.OpenCommand.RaiseCanExecuteChanged(); }); if (!this.IsInDesignMode) { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); var settings = CommonServiceLocator.ServiceLocator.Current.GetInstance <Utilities.Models.Settings>(); var isopen = _proxy.IsFondoAbierto(settings.Sucursal.Clave, settings.Cajero.Id); GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new Utilities.Messages.FondoAperturaCierre { Open = isopen }); } }
public GastoViewModel() { if (!this.IsInDesignMode) { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); _data = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>(); this.Opciones = _proxy.GetTiposGasto(); } this.PropertyChanged += GastoViewModel_PropertyChanged; this.LoadSolicitanteCommand = new RelayCommand(() => { this.Empleado = _data.FindAuditorApertura(this.EmpleadoSearch.Value, this.Cajero.Id); if (this.Empleado != null) { this.EmpleadoSearch = null; } else { MessageBox.Show("Solicitante no valido.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }, () => this.EmpleadoSearch.HasValue); this.SaveCommand = new RelayCommand(() => { var request = new Common.Entities.GastoRequest { Tipo = this.SelectedOption.Value, Monto = this.Monto.Value, Sucursal = this.Sucursal.Clave, CajeroId = this.Cajero.Id, SolicitaId = this.Empleado.Id, Descripcion = this.Descripcion }; _proxy.GenerarGasto(request); MessageBox.Show("Ready"); this.CloseCommand.Execute(null); }, () => this.SelectedOption.HasValue && this.Monto.HasValue && this.Empleado != null); if (this.IsInDesignMode) { this.Descripcion = "desc"; this.EmpleadoSearch = 100; this.Monto = 199.99m; this.Opciones = new Common.Entities.Option[] { new Common.Entities.Option { Id = 1, Text = "a" }, new Common.Entities.Option { Id = 2, Text = "b" }, new Common.Entities.Option { Id = 3, Text = "c" } }; this.SelectedOption = 2; this.Empleado = new Common.Entities.Empleado { Nombre = "aaa", ApellidoMaterno = "mat", ApellidoPaterno = "pat" }; } }
public EntregaEfectivoViewModel() { this.FormasPago = new ObservableCollection <Models.CajaFormaPagoEntrega>(); this.PropertyChanged += EntregaEfectivoViewModel_PropertyChanged; if (!this.IsInDesignMode) { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); _pdata = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>(); this.Data = _proxy.GetEntrega(this.Sucursal.Clave, this.Cajero.Id); if (this.Data != null) { foreach (var item in this.Data.FormasPago) { var fitem = new Models.CajaFormaPagoEntrega { CajaFormaPago = item }; fitem.PropertyChanged += (sender, e) => { this.SaveCommand.RaiseCanExecuteChanged(); }; this.FormasPago.Add(fitem); } } } 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.EntregaRequest { Sucursal = this.Sucursal.Clave, CajeroId = this.Cajero.Id, AuditorId = this.Auditor.Id, Entregar = this.Entrega.Value, FormasPago = this.FormasPago.Select(i => new Common.Entities.EntregaFormaPago { FormaPago = i.CajaFormaPago.FormaPago, Entregar = i.Entregar.Value, Amount = i.EntregarMonto.Value }) }; _proxy.Entrega(request); MessageBox.Show("ready"); this.CloseCommand.Execute(null); }, () => this.Auditor != null && this.Entrega.HasValue && this.FormasPago.All(i => i.Entregar.HasValue && i.EntregarMonto.HasValue)); this.LoadAuditorCommand = new RelayCommand(() => { this.Auditor = _pdata.FindAuditorEntrega(this.SearchAuditor.Value, this.Cajero.Id); if (this.Auditor != null) { this.SearchAuditor = null; } }, () => this.SearchAuditor.HasValue); if (this.IsInDesignMode) { this.SearchAuditor = 100; this.Auditor = new Common.Entities.Empleado { Nombre = "nombre", ApellidoMaterno = "materno", ApellidoPaterno = "paterno", Puesto = (int)Common.Constants.Puesto.SUP }; this.Data = new Common.Entities.CajaFormas { Efectivo = 1099m, FormasPago = new Common.Entities.CajaFormaPago[] { new Common.Entities.CajaFormaPago { FormaPago = Common.Constants.FormaPago.TC, Unidades = 3, Monto = 299m }, new Common.Entities.CajaFormaPago { FormaPago = Common.Constants.FormaPago.VA, Unidades = 100, Monto = 10999m }, new Common.Entities.CajaFormaPago { FormaPago = Common.Constants.FormaPago.CP, Unidades = 1000, Monto = 1000000m } } }; foreach (var item in this.Data.FormasPago) { this.FormasPago.Add(new Models.CajaFormaPagoEntrega { CajaFormaPago = item }); } this.Entrega = 456.7m; } }