示例#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);
            }
        }
示例#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);
            }
        }
示例#3
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);
            }
        }
        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);
            }
        }
示例#5
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 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);
            }
        }