public void ModificarTest()
        {
            bool          paso          = false;
            Ventas        venta         = new Ventas();
            VentasDetalle ventasDetalle = new VentasDetalle();

            venta.VentaId      = 1;
            venta.ClienteId    = 1;
            venta.Fecha        = DateTime.Now;
            venta.Comentario   = "Primera venta a este cliente";
            venta.Descuentos   = 0;
            venta.Fecha        = DateTime.Now;
            venta.Total        = 500;
            venta.TotalGeneral = 590;
            venta.ITBIS        = 90;
            venta.Tipo         = "Credito";
            venta.UsuarioId    = 1;

            ventasDetalle.VentasDetalleId = 1;
            ventasDetalle.VentaId         = 1;
            ventasDetalle.Precio          = 500;
            ventasDetalle.ProductoId      = 1;
            ventasDetalle.Cantidad        = 1;

            venta.VentasDetalle.Add(ventasDetalle);

            paso = VentasBLL.Modificar(venta);

            Assert.AreEqual(paso, true);
        }
예제 #2
0
        public void ModificarTest()
        {
            Ventas ventas = new Ventas();

            ventas.VentaId     = 1;
            ventas.UsuarioId   = 1;
            ventas.ClienteId   = 1;
            ventas.Cuotas      = 4;
            ventas.Balance     = 15555;
            ventas.VehiculoId  = 1;
            ventas.MontoCuotas = 4569;
            ventas.MontoTotal  = 15000;
            ventas.FechaVenta  = DateTime.Now;
            ventas.CuotaDetalles.Add(new CuotaDetalles
            {
                CuotaId   = 1,
                VentaId   = 1,
                UsuarioId = 1,
                Monto     = 1000,
                Balance   = 500,
                Pagada    = false,
                Numero    = 4
            });
            Assert.IsTrue(VentasBLL.Modificar(ventas));
        }
예제 #3
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool   paso = false;
                Ventas venta;

                if (!ValidarClienteId(Convert.ToInt32(ClienteIdTextbox.Text)))
                {
                    MessageBox.Show("Cliente Id no valido", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                if (!ValidarEmpleadoId(Convert.ToInt32(EmpleadoIdTextbox.Text)))
                {
                    MessageBox.Show("Empleado Id no valido", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                if (!ValidarUsuarioId(Convert.ToInt32(UsuarioIdTextBox.Text)))
                {
                    MessageBox.Show("Usuario Id no valido", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                if (!Validar())
                {
                    return;
                }

                venta = LlenaClase();

                if (string.IsNullOrEmpty(VentaIdTextBox.Text) || VentaIdTextBox.Text == "0")
                {
                    paso = VentasBLL.Guardar(venta);
                }
                else
                {
                    if (!ExisteEnDB())
                    {
                        MessageBox.Show("Persona No Encontrada", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                    paso = VentasBLL.Modificar(venta);
                }
                if (paso)
                {
                    MessageBox.Show("Guardado!!", "EXITO", MessageBoxButton.OK, MessageBoxImage.Information);
                    Limpiar();
                }
                else
                {
                    MessageBox.Show(" No guardado!!", "Informacion", MessageBoxButton.OKCancel, MessageBoxImage.Information);
                }
            }
            catch
            {
                MessageBox.Show(" Id no valido !!", "Informacion", MessageBoxButton.OKCancel, MessageBoxImage.Information);
            }
        }
예제 #4
0
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Ventas venta;

            if (!Validar())
            {
                return;
            }

            try
            {
                venta = llenarClase();
                limpiar();

                if (NumeroFacturaNumericUpDown.Value == 0)
                {
                    if (VentasBLL.Guardar(venta))
                    {
                        MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    if (!ExisteEnLaBasedeDatos())
                    {
                        MessageBox.Show("No se puede modificar una venta que no existe", "información!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (VentasBLL.Modificar(venta))
                    {
                        MessageBox.Show("Modificado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo modificar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected void guardarButton_Click(object sender, EventArgs e)
        {
            VentasBLL repositorio = new VentasBLL();
            Ventas    venta       = new Ventas();
            bool      paso        = false;

            if (Validar())
            {
                return;
            }
            else
            {
                //todo: validaciones adicionales
                venta = LlenarClase();

                if (Utils.ToInt(IdTextBox.Text) == 0)
                {
                    paso = repositorio.Guardar(venta);
                    Utils.ShowToastr(this, "Guardado", "Correcto", "success");
                    Limpiar();
                }
                else
                {
                    Ventas    vent       = new Ventas();
                    int       id         = Utils.ToInt(IdTextBox.Text);
                    VentasBLL repository = new VentasBLL();
                    vent = repository.Buscar(id);

                    if (vent != null)
                    {
                        paso = repositorio.Modificar(LlenarClase());
                        Utils.ShowToastr(this, "Modificado", "Correcto", "success");
                    }
                    else
                    {
                        Utils.ShowToastr(this, "No encontrado", "Error", "error");
                    }
                }

                if (paso)
                {
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo guardar", "Error", "error");
                }
            }
        }
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            bool paso = false;

            if (contenedor.ventas.VentaId == 0)
            {
                contenedor.ventas.UsuarioId = UsuarioId;
            }

            contenedor.ventas.ClienteId = ClientesId[ClientesComboBox.SelectedIndex];
            llenarVentaDetalle();

            if (VentaIdTextBox.Text == "0")
            {
                if (!VentasBLL.EntradaValida(contenedor.ventas))
                {
                    MessageBox.Show("Ya ha sido utilizada este ContratoId");
                    return;
                }
                paso = VentasBLL.Guardar(contenedor.ventas);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se Puede Modificar una Venta Que no Existe");
                    return;
                }
                else
                {
                    contenedor.ventas.FechaModificacion = DateTime.Now;
                    paso = VentasBLL.Modificar(contenedor.ventas);
                }
            }

            if (paso)
            {
                ContratosBLL.RestarCantidad(contenedor.ventas.VentaDetalle[0].ContratoId, Convert.ToDecimal(CantidadPendienteLabel.Content));
                Limpiar();
                MessageBox.Show("Guardado");
            }
            else
            {
                MessageBox.Show("No se Pudo Guardar la Venta");
            }
        }
예제 #7
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            Ventas ventas = new Ventas();
            bool   paso   = false;

            if (!Validar())
            {
                return;
            }

            //  ventas = LlenaClase();
            Limpiar();

            //Determinar si es guardar o modificar

            if (string.IsNullOrWhiteSpace(VentaIdTextBox.Text) || (VentaIdTextBox.Text == "0"))
            {
                paso = VentasBLL.Guardar(ventas);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    paso = VentasBLL.Modificar(ventas);
                    MessageBox.Show(" modifico ", "Existo", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    Limpiar();
                    MessageBox.Show("No se puede modificar una venta que no existe", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            //Informar el resultado
            if (paso)
            {
                MessageBox.Show("Guardado!!", "Exito", MessageBoxButton.OK, MessageBoxImage.Information);
                Limpiar();
            }
            else
            {
                MessageBox.Show("No fue posible guardar!!", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #8
0
 private void GuardarButton_Click(object sender, EventArgs e)
 {
     if (Validacion())
     {
         LlenarClases(vent);
         if (VentasBLL.GetLista(Utilidades.StringToInt(ventaIdTextBox.Text)).Count() == 0)
         {
             VentasBLL.Insertar(vent);
             MessageBox.Show("Se guardo la venta realizada");
             limpiar();
         }
         else
         {
             VentasBLL.Modificar(Utilidades.StringToInt(ventaIdTextBox.Text), vent);
             MessageBox.Show("Se modifico la venta");
             limpiar();
         }
     }
 }
        public void ModificarTest()
        {
            //int idVenta = VentasBLL.GetList(x => true)[0].VentaId;
            Ventas ventas = new Ventas();//VentasBLL.Buscar(idVenta);

            ventas.VentaId         = 1;
            ventas.UsuarioId       = 1;
            ventas.Fecha           = DateTime.Now;
            ventas.Descripcion     = "Venta de equipo";
            ventas.NombreCliente   = "Maggy";
            ventas.TelefonoCliente = "829-899-6654";
            ventas.Itbis           = 2700;
            ventas.SubTotal        = 15000;
            ventas.Total           = 17700;

            ventas.Detalle.Add(new VentasDetalle(1, 1, 1, "Iphone 6", 1, 15000, 15000));
            bool paso = VentasBLL.Modificar(ventas);

            Assert.AreEqual(paso, true);
        }
예제 #10
0
        public void ModificarTest()
        {
            bool paso = false;

            Ventas v = new Ventas();

            v.VentaId           = 0;
            v.Fecha             = DateTime.Now;
            v.ClienteId         = 1;
            v.Total             = 1000;
            v.Balance           = 100;
            v.FechaCreacion     = DateTime.Now;
            v.FechaModificacion = DateTime.Now;
            v.UsuarioId         = 1;
            v.VentaDetalle.Add(new VentasDetalle(v.VentaId, 1, 500, 3000));

            paso = VentasBLL.Modificar(v);

            Assert.IsTrue(paso);
        }
예제 #11
0
        private void ButtonGuardar_Click(object sender, EventArgs e)
        {
            if (Validar(2))
            {
                MessageBox.Show("Debe Ingresar Campos Obligatorios", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                Ventas venta = LlenaClase();
                bool   Paso  = false;

                if (VentaIdNumericUpDown.Value == 0)
                {
                    Paso = VentasBLL.Guardar(venta);
                }
                else
                {
                    Paso = VentasBLL.Modificar(venta);
                }

                if (Paso)
                {
                    LimpiarCampos();
                    MessageBox.Show("Guardado!!", "Exito",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PreguntaRecibo fRM = new PreguntaRecibo(venta.VentaId);
                    fRM.ShowDialog();
                }
                else
                {
                    MessageBox.Show("No se pudo guardar!!", "Fallo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #12
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            if (!Validar())
            {
                return;
            }


            /*if (PagoIdTextBox.Text.Trim() == string.Empty)
             * {
             *  MessageBox.Show("El Campo (Pago Id) está vacío.\n\nAsigne un Id al Pago.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
             *  PagoIdTextBox.Text = "0";
             *  PagoIdTextBox.Focus();
             *  PagoIdTextBox.SelectAll();
             *  return;
             * }*/

            if (VentaIdTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Venta Id) está vacío.\n\nAsigne un Id de Venta.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                VentaIdTextBox.Text = "0";
                VentaIdTextBox.Focus();
                VentaIdTextBox.SelectAll();
                return;
            }

            if (UsuarioIdComboBox.Text == string.Empty)
            {
                MessageBox.Show("El Campo (Usuario Id) está vacío.\n\nPorfavor, Seleccione su Nombre de Usuario.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                UsuarioIdComboBox.IsDropDownOpen = true;
                return;
            }

            Ventas venta = VentasBLL.Buscar(pago.VentaId);

            if (venta.Balance == 0)
            {
                MessageBox.Show("Esta venta ha sido saldada...", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            pago.PagoId          = int.Parse(PagoIdTextBox.Text);
            pago.UsuarioId       = int.Parse(UsuarioIdComboBox.SelectedValue.ToString());
            pago.VentaId         = int.Parse(VentaIdTextBox.Text);
            pago.Fecha           = DateTime.Parse(FechaTextBox.Text);
            pago.Descuento       = float.Parse(DescuentoTextBox.Text);
            pago.Monto           = float.Parse(MontoTextBox.Text);
            pago.BalanceAnterior = float.Parse(TotalPendienteTextBox.Text);

            var paso = PagosBLL.Guardar(this.pago);

            if (paso)
            {
                venta.Descuento += pago.Descuento;
                venta.Balance   -= (pago.Monto + pago.Descuento);
                VentasBLL.Modificar(venta);

                pago.PagosDetalle.Clear();
                Cuotas cuota;

                foreach (PagosDetalle item in listado)
                {
                    item.PagoId = pago.PagoId;
                    PagosDetalleBLL.Guardar(item);

                    cuota         = new Cuotas();
                    cuota         = CuotasBLL.Buscar(item.CuotaId);
                    cuota.Balence = item.Balance;
                    CuotasBLL.Modificar(cuota);
                }

                Limpiar();
                MessageBox.Show("Pago Realizado (Guardado)", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("Verifique los datos introcidos e intetelo de nuevo", "Datos no válido", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }