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);
        }
        public void ExisteTest()
        {
            bool paso = false;

            paso = VentasBLL.Existe(1);
            Assert.AreEqual(paso, true);
        }
Esempio n. 3
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));
        }
        private void EliminarButton_Click(object sender, RoutedEventArgs e)
        {
            Contratos AnteriorContrato = ContratosBLL.Buscar(contrato.ContratoId);

            if (AnteriorContrato == null)
            {
                MessageBox.Show("No se Puede Eliminar un contrato que no existe");
                return;
            }

            List <Ventas> ventas = VentasBLL.GetList(p => true);

            foreach (var item in ventas)
            {
                if (item.VentaDetalle[0].ContratoId == contrato.ContratoId)
                {
                    MessageBox.Show("No se puede eliminar este contrato ya que tiene una venta");
                    return;
                }
            }

            if (ContratosBLL.Eliminar(contrato.ContratoId))
            {
                CacaosBLL.DevolverCacao(contrato.CacaoId, contrato.Cantidad);
                MessageBox.Show("Eliminado");
                Limpiar();
            }
            else
            {
                MessageBox.Show("No se puede eliminar un contrato que no existe");
            }
        }
Esempio n. 5
0
        private void ButtonRecibo_Click(object sender, EventArgs e)
        {
            int    id    = Convert.ToInt32(VentaIdNumericUpDown.Value);
            Ventas venta = VentasBLL.Buscar(id);

            int           Id     = Convert.ToInt32(VentaIdNumericUpDown.Value);
            List <Ventas> ventas = new List <Ventas>();

            if (venta != null)
            {
                if (VentaIdNumericUpDown.Value > 0)
                {
                    ventas = VentasBLL.GetList(v => v.VentaId == Id);
                    vRecibo vRecibo = new vRecibo(ventas);
                    vRecibo.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Introduzca un Id!!", "Fallo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("No Hay Una Venta Con Ese Id!!", "Fallo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        private void CVentas_Load(object sender, EventArgs e)
        {
            var listado = new List <Ventas>();

            if (CriterioTextBox.Text.Trim().Length > 0)
            {
                switch (FiltrarComboBox.SelectedIndex)
                {
                case 0:    //Todo
                    listado = VentasBLL.GetList(p => true);
                    break;

                case 1:
                    int id = Convert.ToInt32(CriterioTextBox.Text);
                    //listado = VentasBLL.GetList(p => p.CodigoCliente == id);
                    break;

                    //break;

                    //    case 5:
                    //        listado = VentasBLL.GetList(p => true);
                    //        /listado = listado.Where(c => DateTime.Parse(c.Fecha) >= DesdeDateTimePicker.Value.Date && DateTime.Parse(c.Fecha) <= HastaDateTimePicker.Value.Date).ToList();
                    //        break;
                }
                //listado = listado.Where(c => DateTime.Parse(c.Fecha) >= DesdeDateTimePicker.Value.Date && DateTime.Parse(c.Fecha) <= HastaDateTimePicker.Value.Date).ToList();
            }
            else
            {
                listado = VentasBLL.GetList(p => true);
            }

            ConsultaDataGridView.DataSource = null;
            ConsultaDataGridView.DataSource = listado;
        }
        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);
            }
        }
Esempio n. 8
0
        public void GetListTest()
        {
            var lista = new List <Ventas>();

            lista = VentasBLL.GetList(p => true);
            Assert.IsNotNull(lista);
        }
Esempio n. 9
0
        public void EliminarTest()
        {
            bool paso;

            paso = VentasBLL.Eliminar(1);
            Assert.AreEqual(paso, true);
        }
        public void GuardarTest()
        {
            Ventas v = new Ventas();

            v.VentaId           = 1;
            v.Fecha             = DateTime.Now;
            v.ClienteId         = 1;
            v.Total             = 100;
            v.Balance           = 100;
            v.FechaCreacion     = DateTime.Now;
            v.FechaModificacion = DateTime.Now;
            v.UsuarioId         = 1;
            v.VentaDetalle.Add(new VentasDetalle
            {
                VentaDetalleId = 0,
                VentaId        = v.VentaId,
                ContratoId     = 1,
                Cantidad       = 500,
                Precio         = 300,
            });

            bool paso = VentasBLL.Guardar(v);

            Assert.IsTrue(paso);
        }
Esempio n. 11
0
        public void BuscarTest()
        {
            Ventas ventas;

            ventas = VentasBLL.Buscar(2);
            Assert.IsNotNull(ventas);
        }
Esempio n. 12
0
        private void EliminarButton_Click(object sender, RoutedEventArgs e)
        {
            int id;

            int.TryParse(VentaIdTextBox.Text, out id);
            RepositorioBase <Ventas> db = new RepositorioBase <Ventas>();

            try
            {
                if (!string.IsNullOrWhiteSpace(VentaIdTextBox.Text) && (!string.IsNullOrWhiteSpace(ClienteIdCombox.Text)))
                {
                    MessageBox.Show("Deben de estar llenos los campos", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                Limpiar();

                if (VentasBLL.Eliminar(id))
                {
                    MessageBox.Show("Eliminado", "Exito", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show(VentaIdTextBox.Text, "No se puede eliminar una venta que no existe");
                }
            }
            catch
            {
            }
        }
Esempio n. 13
0
        public void GetListTest()
        {
            var listado = new List <Ventas>();

            listado = VentasBLL.GetList(s => true);
            Assert.AreEqual(listado, listado);
        }
Esempio n. 14
0
        private void VentaBuscarButton_Click(object sender, RoutedEventArgs e)
        {
            float total = 0;

            if (VentaIdTextBox.Text.Length > 0)
            {
                venta = VentasBLL.Buscar(int.Parse(VentaIdTextBox.Text));

                if (venta.VentaId > 0)
                {
                    //busca las cuotas pendientes y la muestra en el grid...
                    listado = new List <PagosDetalle>();
                    var item = venta.Cuotas.FindAll(e => e.Balence > 0);

                    foreach (Cuotas cuota in item)
                    {
                        listado.Add(new PagosDetalle(0, cuota.CuotaId, cuota.Monto, cuota.Balence, 0, cuota.NumCuota, 0));
                        total += cuota.Balence;
                    }

                    DetalleDataGrid.ItemsSource = null;
                    DetalleDataGrid.ItemsSource = listado;
                    TotalPendienteTextBox.Text  = total.ToString();
                }
            }
            else
            {
                MessageBox.Show($"Debe colocar el numero de la venta", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        private void EliminarButton_Click(object sender, RoutedEventArgs e)
        {
            Ventas AnteriorVenta = VentasBLL.Buscar(contenedor.ventas.VentaId);

            if (AnteriorVenta == null)
            {
                MessageBox.Show("No se Puede Eliminar un venta que no existe");
                return;
            }

            List <Pagos> pagos = PagosBLL.GetList(p => true);

            foreach (var item in pagos)
            {
                if (item.PagoDetalle[0].VentaId == contenedor.ventas.VentaId)
                {
                    MessageBox.Show("No se puede eliminar esta ya que tiene un pago");
                    return;
                }
            }

            if (VentasBLL.Eliminar(contenedor.ventas.VentaId))
            {
                ContratosBLL.RestablecerCantidadPendiente(contenedor.ventas.VentaDetalle[0].ContratoId);
                Limpiar();
                MessageBox.Show("Eliminado");
            }
            else
            {
                MessageBox.Show("No se Puede Eliminar Una Venta Que no Existe");
            }
        }
Esempio n. 16
0
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            Pagos pago = PagosBLL.Buscar(contenedor.pagos.PagoId);

            if (pago != null)
            {
                contenedor.pagos = pago;
                llenarDataGrid();
                obtenerListado();
                UsuarioLabel.Content = obtenerNombreUsuario(contenedor.pagos.UsuarioId);

                Ventas venta = VentasBLL.Buscar(Convert.ToInt32(VentaComboBox.SelectedItem));
                BalanceLabel.Content = Convert.ToString(venta.Balance);

                ClientesComboBox.IsEnabled = false;
                VentaComboBox.IsEnabled    = false;

                reCargar();
            }
            else
            {
                limpiar();
                MessageBox.Show("Pago no encontrado");
            }
        }
Esempio n. 17
0
 private void BuscarButton_Click(object sender, EventArgs e)
 {
     if (ValidarId("Ingrese el id de la venta que quiere buscar") && Search())
     {
         Fill(VentasBLL.Buscar(Utilidades.StringToInt(ventaIdTextBox.Text)));
     }
 }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int Id;

            this.FechaTextBox.Text = string.Format("{0:G}", DateTime.Now);
            if (!Page.IsPostBack)
            {
                LLenarComboVendedor();


                if (Request.QueryString["Id"] != null)
                {
                    Id = Utilidades.TOINT(Request.QueryString["Id"].ToString());

                    if (Id > 0)
                    {
                        Ventas ventas = new Ventas();
                        VentasBLL.Buscar(Id);

                        Utilidades.ShowToastr(this, "Registro no encontrado", "Error", "Danger");
                    }
                    else
                    {
                        IdTextBox.Text = Id.ToString();
                    }
                }
            }
        }
Esempio n. 19
0
        private void Filtrarbutton_Click(object sender, EventArgs e)
        {
            if (filtroComboBox.SelectedIndex == 0)
            {
                VentasdataGridView.DataSource = VentasBLL.GetLista();
            }
            if (ValidarFiltrar())
            {
                if (filtroComboBox.SelectedIndex == 1)
                {
                    VentasdataGridView.DataSource = VentasBLL.GetLista(DesdeDateTimePicker.Value, HastadateTimePicker.Value);
                }
                if (filtroComboBox.SelectedIndex == 2)
                {
                    VentasdataGridView.DataSource = VentasBLL.GetListaTipo(Utilidades.StringToInt(filtroTextBox.Text));
                }
                if (filtroComboBox.SelectedIndex == 3)
                {
                    VentasdataGridView.DataSource = VentasBLL.GetLista(Utilidades.StringToInt(filtroTextBox.Text));
                }

                if (filtroComboBox.SelectedIndex == 4)

                {
                    VentasdataGridView.DataSource = VentasBLL.GetListaDetalle(Utilidades.StringToInt(filtroComboBox.Text));
                }
            }
        }
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            Ventas VentaAnterior = VentasBLL.Buscar(contenedor.ventas.VentaId);

            if (VentaAnterior != null)
            {
                contenedor.ventas = VentaAnterior;
                llenarDataGrid();
                obtenerListado();
                UsuarioLabel.Content = obtenerNombreUsuario(contenedor.ventas.UsuarioId);

                Contratos contrato = ContratosBLL.Buscar(Convert.ToInt32(ContratoIdComboBox.SelectedItem));
                CantidadPendienteLabel.Content = Convert.ToString(contrato.CantidadPendiente);

                ClientesComboBox.IsEnabled   = false;
                ContratoIdComboBox.IsEnabled = false;

                Recargar();
            }
            else
            {
                Limpiar();
                MessageBox.Show("Venta No Encontrada");
            }
        }
Esempio n. 21
0
        private bool ExisteEnLaBaseDeDatos()
        {
            RepositorioBase <Ventas> db = new RepositorioBase <Ventas>();
            Ventas ventas = VentasBLL.Buscar((int)VentaIdTextBox.Text.ToInt());

            return(ventas != null);
        }
Esempio n. 22
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtClientes.Text) ||
                string.IsNullOrEmpty(DatosFactura.DataSource.ToString()))
            {
                MessageBox.Show("Debe completar todos los datos");
            }
            else
            {
                int id;
                int.TryParse(txtFacturaId.Text, out id);
                v.Fecha     = txtFecha.Value;
                v.Nombre    = txtClientes.Text;
                v.Direccion = txtDireccion.Text;
                v.Articulos = txtArticulos.Text;
                v.Cantidad  = Convert.ToInt32(txtCantidad.Text);
                v.Total     = Convert.ToInt32(txtTotal.Text);
                v.FacturaId = id;



                if (VentasBLL.insertar(v))
                {
                    MessageBox.Show("Datos registrados");
                    txtClientes.Items.Clear();
                    txtDireccion.Clear();
                    txtArticulos.Items.Clear();
                    txtCantidad.Clear();
                }
            }
        }
Esempio n. 23
0
        public void EliminarTest()
        {
            bool paso = false;

            paso = VentasBLL.Eliminar(1);

            Assert.IsTrue(paso);
        }
Esempio n. 24
0
        private void LlenarImporte()
        {
            decimal cantidad, precio;

            cantidad            = ToDecimal(CantidadTextBox.Text);
            precio              = ToDecimal(PrecioTextBox.Text);
            ImporteTextBox.Text = VentasBLL.Importe(cantidad, precio).ToString();
        }
Esempio n. 25
0
        private void ButtonBuscar_Click(object sender, EventArgs e)
        {
            ventas = VentasBLL.GetList(v => v.VentaId == id);
            vRecibo recibo = new vRecibo(ventas);

            recibo.ShowDialog();
            Hide();
        }
Esempio n. 26
0
        public void ExisteVentaTest()
        {
            bool paso;

            paso = VentasBLL.ExisteVenta();

            Assert.IsTrue(paso);
        }
Esempio n. 27
0
        public void BuscarTest()
        {
            int    id    = 1;
            Ventas venta = new Ventas();

            venta = VentasBLL.Buscar(id);
            Assert.IsNotNull(venta);
        }
        public void ContratoDisponibleTest()
        {
            Ventas venta = VentasBLL.Buscar(1);

            bool paso = VentasBLL.ContratoDisponible(venta);

            Assert.IsTrue(paso);
        }
        public void BuscarTest()
        {
            int    idVenta = VentasBLL.GetList(x => true)[0].VentaId;
            Ventas ventas  = VentasBLL.Buscar(idVenta);
            bool   paso    = ventas.Detalle.Count > 0;

            Assert.AreEqual(true, paso);
        }
Esempio n. 30
0
 private void BuscarIdbutton_Click_1(object sender, EventArgs e)
 {
     if (validarId("Favor ingresar el id de la Venta que desea buscar") && ValidarBuscar())
     {
         factura = VentasBLL.Buscar(ut.StringInt(FacturaIdtextBox.Text));
     }
     Llenar();
 }