コード例 #1
0
ファイル: FrmCompras.xaml.cs プロジェクト: hfmm99/Empenos
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            características = new List <CaracterísticaValor>();

            var bd = new EmpeñosDataContext();

            parámetros = bd.Parámetros.FirstOrDefault();

            cmbCategorías.Items.Insert(0, new KeyValuePair <int?, string>(null, string.Empty));

            foreach (var cat in bd.Categorías.OrderBy(cat => cat.Nombre))
            {
                cmbCategorías.Items.Add(new KeyValuePair <int?, string>(cat.Código, cat.Nombre));
            }

            cmbCategorías.SelectedIndex = 0;

            dtpFecha.SelectedDate         = DateTime.Today;
            pnlDetalleArtículo.Visibility = Visibility.Collapsed;
            txtCódigo.Focus();

            if (códigoCompra.HasValue)
            {
                var compra = bd.Compras.SingleOrDefault(c => c.Código == códigoCompra);
                if (compra != null)
                {
                    txtCódigo.Text                  = compra.Código.ToString();
                    txtCódigo.IsReadOnly            = true;
                    chkImprimirAlGuardar.Visibility = Visibility.Collapsed;

                    dtpFecha.SelectedDate = compra.Fecha;

                    if (compra.Cliente != null)
                    {
                        txtClientes.SelectedItem = new KeyValuePair <string, string>(compra.Cliente.Código, compra.Cliente.NombreCompleto);
                        txtClientes.Text         = compra.Cliente.NombreCompleto;
                    }

                    txtTotalCostoCompra.AsInt = compra.CostoTotal;

                    foreach (ComprasDetalle det in compra.ComprasDetalles)
                    {
                        lstArtículos.Items.Add(det.Artículo);
                        det.Artículo.Artículos_Características.ToArray();
                    }

                    dtpFecha.Focus();
                }
            }
        }
コード例 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var bd = new EmpeñosDataContext();

            parámetros = bd.Parámetros.FirstOrDefault();

            dtpFecha.SelectedDate = DateTime.Today;

            txtCódigo.Focus();

            if (códigoVenta.HasValue)
            {
                var venta = bd.Ventas.SingleOrDefault(c => c.Código == códigoVenta);
                if (venta != null)
                {
                    txtCódigo.Text                  = venta.Código.ToString();
                    txtCódigo.IsReadOnly            = true;
                    chkImprimirAlGuardar.Visibility = Visibility.Collapsed;
                    dtpFecha.SelectedDate           = venta.Fecha;
                    cmbEstado.SelectedIndex         = (int)venta.Estado;
                    txtCódigo.IsEnabled             = false;
                    txtMontoAPagar.Text             = venta.Total.ToString();

                    if (venta.Cliente != null)
                    {
                        txtClientes.SelectedItem = new KeyValuePair <string, string>(venta.Cliente.Código, venta.Cliente.NombreCompleto);
                        txtClientes.Text         = venta.Cliente.NombreCompleto;
                    }

                    grdArtículos.ItemsSource = null;

                    foreach (var det in venta.VentasDetalles)
                    {
                        listaArtículos.Add(det.Artículo);
                    }

                    grdArtículos.ItemsSource = listaArtículos;

                    ActualizarTotales();

                    dtpFecha.Focus();
                }
            }

            grdArtículos.ItemsSource = listaArtículos;
        }
コード例 #3
0
        protected override void CrearComportamiento(string cadena, DeclaraciónDeContexto declaración, int desplazamiento)
        {
            var parámetro = new Parámetro
            {
                Tipo   = TipoDeVariable,
                Nombre = NombreDeVariable
            };

            declaración.CrearParámetro(parámetro);

            base.CrearComportamiento(cadena, declaración, desplazamiento);

            var cargarDatoDeParámetro = new CargarDatoEnVariable(NombreDeVariable, cadena)
            {
                Inicio = desplazamiento
            };

            declaración.Instrucciones.Enqueue(cargarDatoDeParámetro);
        }
コード例 #4
0
ファイル: FrmEmpeños.xaml.cs プロジェクト: hfmm99/Empenos
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            #region Configurar Firma

            inkFirma.SetSigCompressionMode(2);
            inkFirma.SetEncryptionMode(2);
            inkFirma.AutoKeyStart();
            inkFirma.SetAutoKeyData("La Salvada");
            inkFirma.AutoKeyFinish();

            #endregion

            características       = new List <CaracterísticaValor>();
            pagos                 = new ObservableCollection <EmpeñosPago>();
            gridPagos.ItemsSource = pagos;

            var bd = new EmpeñosDataContext();
            parámetros = bd.Parámetros.FirstOrDefault();

            cmbCategorías.Items.Insert(0, new KeyValuePair <int?, string>(null, string.Empty));

            foreach (var cat in bd.Categorías.OrderBy(cat => cat.Nombre))
            {
                cmbCategorías.Items.Add(new KeyValuePair <int?, string>(cat.Código, cat.Nombre));
            }

            cmbCategorías.SelectedIndex = 0;


            dtpFecha.SelectedDate         = DateTime.Today;
            pnlDetalleArtículo.Visibility = Visibility.Collapsed;
            txtCódigo.Focus();

            if (códigoEmpeño.HasValue)
            {
                var empeño = bd.Empeños.SingleOrDefault(c => c.Código == códigoEmpeño);
                if (empeño != null)
                {
                    if (!reempeñar)
                    {
                        txtCódigo.Text                  = empeño.Código.ToString();
                        txtCódigo.IsReadOnly            = true;
                        chkImprimirAlGuardar.Visibility = Visibility.Collapsed;
                        dtpFecha.SelectedDate           = empeño.Fecha;
                        cmbEstado.SelectedIndex         = (int)empeño.Estado;
                        gridArtículos.IsEnabled         = pnlListaPagos.IsEnabled = btnGuardar.IsEnabled = empeño.Estado != (byte)EstadosEmpeño.Quedado;
                        txtCódigo.IsEnabled             = false; ///*****///
                        tabPagos.IsEnabled              = true;
                    }

                    if (empeño.Cliente != null)
                    {
                        txtClientes.SelectedItem = new KeyValuePair <string, string>(empeño.Cliente.Código, empeño.Cliente.NombreCompleto);
                        txtClientes.Text         = empeño.Cliente.NombreCompleto;
                    }

                    txtPlazo.AsInt = empeño.Plazo;
                    txtPorcentajeIntereses.AsDecimal = empeño.PorcentajeInterés;
                    txtTotalMontoPréstamo.AsInt      = empeño.TotalMontoPréstamo;
                    txtNotasEmpeño.Text = empeño.Notas;

                    foreach (EmpeñosDetalle det in empeño.EmpeñosDetalles)
                    {
                        lstArtículos.Items.Add(det.Artículo);
                        det.Artículo.Artículos_Características.ToArray();
                    }

                    if (reempeñar)
                    {
                        txtPlazo.AsInt = parámetros.Plazo;
                        txtPorcentajeIntereses.AsDecimal = Math.Round(parámetros.PorcentajeInterés, 2);
                    }

                    if (!reempeñar)
                    {
                        pagos.Clear();
                        foreach (var pago in empeño.EmpeñosPagos)
                        {
                            pago.PropertyChanged += pago_PropertyChanged;
                            pagos.Add(pago);
                        }
                    }
                    ActualizarTotales();

                    #region Firma

                    // Cargar Firma
                    if (empeño.Firma != null && empeño.Firma.Length > 0)
                    {
                        inkFirma.SetSigString(empeño.Firma);
                    }

                    inkFirma.SetTabletState(1);

                    #endregion

                    dtpFecha.Focus();
                }
            }
            else
            {
                txtPlazo.AsInt = parámetros.Plazo;
                txtPorcentajeIntereses.AsDecimal = Math.Round(parámetros.PorcentajeInterés, 2);
            }
            if (txtPlazo.Text != "1")
            {
                labelMeses.Content = "meses";
            }
        }
コード例 #5
0
        private void ActualizarTotales()
        {
            var bd = new EmpeñosDataContext();

            parámetros = bd.Parámetros.FirstOrDefault();

            /*
             * var pagos = gridPagos.Items.OfType<EmpeñosPago>().ToArray();
             *
             * if (pagos.Length > 0)
             * {
             *  txtTotalInteresesCancelados.AsInt = pagos.Sum(p => p.Intereses);
             *
             *  int totalDePréstamoCancelado = pagos.Sum(p => p.Abono);
             *
             *  txtTotalDePréstamoCancelado.AsInt = totalDePréstamoCancelado;
             *
             *  int saldo = txtTotalMontoPréstamo.AsInt - totalDePréstamoCancelado;
             *  txtSaldoDelPréstamo.AsInt = saldo;
             *  btnNuevoPago.IsEnabled = btnRetirar.IsEnabled = saldo > 0;
             *  cmbEstado.SelectedIndex = saldo == 0 ? (int)EstadosEmpeño.Retirado : (int)EstadosEmpeño.Activo;
             *
             *  dtpFechaVencimiento.SelectedDate = pagos.Max(p => p.FechaCuota).AddMonths(parámetros.Plazo);
             * }
             * else
             * {
             *  txtTotalInteresesCancelados.AsInt = txtTotalDePréstamoCancelado.AsInt = 0;
             *  txtSaldoDelPréstamo.AsInt = txtTotalMontoPréstamo.AsInt;
             *  dtpFechaVencimiento.SelectedDate = dtpFecha.SelectedDate.Value.AddMonths(parámetros.Plazo);
             * }
             *
             * TimeSpan díasRestantes = dtpFechaVencimiento.SelectedDate.Value - DateTime.Today;
             *
             * if (díasRestantes.Days > 30)
             *  ctrlIndicador.Estado = Controles.EstadoIndicador.Verde;
             * else if (díasRestantes.Days > 3)
             *  ctrlIndicador.Estado = Controles.EstadoIndicador.Amarillo;
             * else
             *  ctrlIndicador.Estado = Controles.EstadoIndicador.Rojo;
             * */
            var suma     = listaArtículos.Sum(art => art.Precio);
            var impuesto = 0;
            var total    = 0;

            DateTime fecha_x = new DateTime(2021, 2, 28);                                  // Este codigo de fecha se agrego para no hacer cambios en BD
            DateTime fecha_y = new DateTime(2020, 06, 27);                                 // En este fecha aproximadamente se hicieron los cambios en Git
            DateTime fecha_z = new DateTime(2021, 10, 19);                                 // En esta fecha se volvio a poner el IVA en 13%
            int      result1 = DateTime.Compare((DateTime)dtpFecha.SelectedDate, fecha_x); // se paso de 0% a 13% y luego a 4% de IVA
            int      result2 = DateTime.Compare((DateTime)dtpFecha.SelectedDate, fecha_y);
            int      result3 = DateTime.Compare((DateTime)dtpFecha.SelectedDate, fecha_z);

            if (result1 >= 0)
            {
                impuesto = (int)(suma * 0.04);
            }
            else if (result2 > 0)
            {
                impuesto = (int)(suma * 0.13);
            }
            else if (result2 <= 0)
            {
                impuesto = 0;
            }
            else if (result3 >= 0)
            {
                impuesto = (int)(suma * parámetros.IVA); // cambiar a 13% el IVA en la tabla de parametros
            }
            total                   = (int)(suma + impuesto);
            suma                    = listaArtículos.Sum(art => art.Precio);
            impuesto                = (int)(suma * parámetros.IVA);
            total                   = (int)(suma + impuesto);
            txtIVA.Text             = impuesto.ToString();
            txtTotalMontoVenta.Text = suma.ToString();
            txtMontoAPagar.Text     = total.ToString();
        }