Ejemplo n.º 1
0
        public static bool Guardar(Vendedores vendedor)
        {
            bool retorno = false;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    if (Buscar(vendedor.VendedorId) == null)
                    {
                        conexion.Vendedor.Add(vendedor);
                    }
                    else
                    {
                        conexion.Entry(vendedor).State = EntityState.Modified;
                    }
                    conexion.SaveChanges();

                    retorno = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }

                return(retorno);
            }
        }
Ejemplo n.º 2
0
        public static bool Insertar(Productos productos)
        {
            bool obtener = false;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    if (Buscar(productos.IdProducto) == null)
                    {
                        conexion.Producto.Add(productos);
                    }
                    else
                    {
                        conexion.Entry(productos).State = EntityState.Modified;
                    }
                    conexion.SaveChanges();

                    obtener = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    //throw;
                }
                return(obtener);
            }
        }
        public static Usuarios Buscar(int id)
        {
            var us   = new Usuarios();
            var conn = new ProyectoFinalDb();

            us = conn.Usuario.Find(id);
            return(us);
        }
        public static List <Usuarios> GetLista(int usuarioId)
        {
            List <Usuarios> lista = new List <Usuarios>();

            var db = new ProyectoFinalDb();

            lista = db.Usuario.Where(p => p.Usuarioid == usuarioId).ToList();

            return(lista);
        }
        public static List <Usuarios> GetLista()
        {
            List <Usuarios> lista = new List <Usuarios>();

            var db = new ProyectoFinalDb();

            lista = db.Usuario.ToList();

            return(lista);
        }
        public static List <Proveedores> GetLista()
        {
            List <Proveedores> lista = new List <Proveedores>();

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    lista = conexion.Proveedore.ToList();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
                return(lista);
            }
        }
Ejemplo n.º 7
0
        public static List <Productos> ListaCombo()
        {
            List <Productos> lista = null;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    lista = conexion.Producto.Where(p => p.Cantidad <= 0 && p.Total <= 0).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(lista);
        }
Ejemplo n.º 8
0
        public static Vendedores Buscar(int vendedorId)
        {
            var vendedor = new Vendedores();

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    vendedor = conexion.Vendedor.Find(vendedorId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(vendedor);
        }
Ejemplo n.º 9
0
        public static List <Vendedores> GetListaId(int vendedorId)
        {
            List <Vendedores> lista = new List <Vendedores>();

            using (var db = new ProyectoFinalDb())
            {
                try
                {
                    lista = db.Vendedor.Where(p => p.VendedorId == vendedorId).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
                return(lista);
            }
        }
Ejemplo n.º 10
0
        public static List <Vendedores> GetListNombre(string nombre)
        {
            List <Vendedores> lista = new List <Vendedores>();

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    lista = conexion.Vendedor.Where(n => string.Equals(n.Nombre, nombre)).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(lista);
        }
Ejemplo n.º 11
0
        public static Productos Buscar(int productoId)
        {
            var producto = new Productos();

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    producto = conexion.Producto.Find(productoId);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(producto);
        }
Ejemplo n.º 12
0
        public static List <TiposVehiculos> GetLista()
        {
            List <TiposVehiculos> lista = new List <TiposVehiculos>();

            using (var db = new ProyectoFinalDb())
            {
                try
                {
                    lista = db.TiposVehiculos.ToList();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    // throw;
                }
                return(lista);
            }
        }
Ejemplo n.º 13
0
        public static List <Vendedores> GetLista()
        {
            List <Vendedores> lista = new List <Vendedores>();

            using (var db = new ProyectoFinalDb())
            {
                try
                {
                    lista = db.Vendedor.ToList();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    throw;
                }
                return(lista);
            }
        }
Ejemplo n.º 14
0
        public static List <Productos> GetLista(int idProducto)
        {
            List <Productos> lista = new List <Productos>();

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    lista = conexion.Producto.Where(p => p.IdProducto == idProducto).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(lista);
        }
        public static bool Insertar(Proveedores proveedor)
        {
            bool resultado = false;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    conexion.Proveedore.Add(proveedor);
                    conexion.SaveChanges();
                    resultado = true;
                }
                catch (Exception)
                {
                    throw;
                }
                return(resultado);
            }
        }
Ejemplo n.º 16
0
        public static bool Insertar(TiposVehiculos tVehiculos)
        {
            bool resultado = false;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    conexion.TiposVehiculos.Add(tVehiculos);
                    conexion.SaveChanges();
                    resultado = true;
                }
                catch (Exception)
                {
                    throw;
                }
                return(resultado);
            }
        }
Ejemplo n.º 17
0
        public static Double GetPrecio(int productoId)
        {
            Double precio = 0;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    Productos p = conexion.Producto.Where(prod => prod.IdProducto == productoId).FirstOrDefault();
                    precio = p.Precio;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    throw;
                }
                return(precio);
            }
        }
Ejemplo n.º 18
0
        public static void Eliminar(Vendedores vendedor)
        {
            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    if (vendedor != null)
                    {
                        conexion.Entry(vendedor).State = EntityState.Deleted;

                        conexion.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    throw;
                }
            }
        }
        public static bool Insertar(Facturas factura)
        {
            bool resultado = false;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    conexion.Factura.Add(factura);
                    conexion.SaveChanges();
                    resultado = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    throw;
                }
                return(resultado);
            }
        }
        public static Facturas Buscar(int facturaId)
        {
            Facturas factura = null;

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    factura = conexion.Factura.Find(facturaId);
                    if (factura != null)
                    {
                        factura.Productos.Count();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(factura);
        }
Ejemplo n.º 21
0
        public static List <Productos> Productos(int facturaId)
        {
            var producto = new List <Productos>();

            using (var conexion = new ProyectoFinalDb())
            {
                try
                {
                    var factura = BLL.FacturasBLL.Buscar(facturaId);
                    if (factura != null)
                    {
                        producto = factura.Productos;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(producto);
        }
        public static bool Guardar(Usuarios usuario)
        {
            bool retorno = false;

            try
            {
                var db = new ProyectoFinalDb();

                db.Usuario.Add(usuario);

                db.SaveChanges();

                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(retorno);
        }
        public static bool Eliminar(int id)
        {
            bool obtener = false;

            using (var db = new ProyectoFinalDb())
            {
                try
                {
                    Usuarios us = db.Usuario.Find(id);

                    db.Usuario.Remove(us);

                    db.SaveChanges();

                    obtener = true;
                }
                catch (Exception)
                {
                    throw;
                }
                return(obtener);
            }
        }