public ActionResult Create([Bind(Include = "ProductoId,Descripcion,Costo,Precio")] Productos productos)
        {
            if (ModelState.IsValid)
            {
                db.Producto.Add(productos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productos));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ClienteId,Nombres")] Clientes clientes)
        {
            if (ModelState.IsValid)
            {
                db.Cliente.Add(clientes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clientes));
        }
        public ActionResult Create([Bind(Include = "CotizacionId,Fecha,Monto,ClienteId")] Cotizaciones cotizaciones)
        {
            if (ModelState.IsValid)
            {
                db.Cotizacion.Add(cotizaciones);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClienteId = new SelectList(db.Cliente, "ClienteId", "Nombres", cotizaciones.ClienteId);
            return(View(cotizaciones));
        }
        public ActionResult Create([Bind(Include = "DetalleId,CotizacionId,ProductoId,Descripcion,Cantidad,Precio")] CotizacionesDetalles cotizacionesDetalles)
        {
            if (ModelState.IsValid)
            {
                db.CotizacionDetalle.Add(cotizacionesDetalles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CotizacionId = new SelectList(db.Cotizacion, "CotizacionId", "CotizacionId", cotizacionesDetalles.CotizacionId);
            ViewBag.ProductoId   = new SelectList(db.Producto, "ProductoId", "Descripcion", cotizacionesDetalles.ProductoId);
            return(View(cotizacionesDetalles));
        }
        public static bool Guardar(Productos productos)
        {
            bool retorno = false;

            try
            {
                using (var db = new EjemploDetalleDb())
                {
                    if (Buscar(productos.ProductoId) == null)
                    {
                        db.Producto.Add(productos);
                    }
                    else
                    {
                        db.Entry(productos).State = EntityState.Modified;
                    }

                    db.SaveChanges();
                }
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
        public static bool Guardar(Models.CotizacionesDetalles detalle)
        {
            bool retorno = false;

            try
            {
                using (var db = new EjemploDetalleDb())
                {
                    if (Buscar(detalle.DetalleId) == null)
                    {
                        db.CotizacionDetalle.Add(detalle);
                    }
                    else
                    {
                        db.Entry(detalle).State = EntityState.Modified;
                    }

                    db.SaveChanges();
                }
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
        public static bool Guardar(Clientes cliente)
        {
            bool retorno = false;

            try
            {
                using (var db = new EjemploDetalleDb())
                {
                    if (Buscar(cliente.ClienteId) == null)
                    {
                        db.Cliente.Add(cliente);
                    }
                    else
                    {
                        db.Entry(cliente).State = EntityState.Modified;
                    }

                    db.SaveChanges();
                }
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
Beispiel #8
0
        public static bool Insertar(Grupos gp)
        {
            bool retorno = false;

            try
            {
                var db = new EjemploDetalleDb();

                db.Grupos.Add(gp);
                var gr = db.Grupos.Add(gp);
                foreach (var est in gp.Estudiantes)
                {
                    db.Entry(est).State = EntityState.Unchanged;
                }
                db.SaveChanges();
                //db.Dispose();

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

            return(retorno);
        }
Beispiel #9
0
        public static bool Guardar(Cotizaciones cotizacion)
        {
            bool retorno = false;

            try
            {
                using (var db = new EjemploDetalleDb())
                {
                    if (Buscar(cotizacion.CotizacionId) == null)
                    {
                        db.Cotizacion.Add(cotizacion);
                    }
                    else
                    {
                        db.Entry(cotizacion).State = EntityState.Modified;
                    }

                    foreach (var cotizaciones in cotizacion.Detalle)
                    {
                        db.Entry(cotizaciones).State = EntityState.Unchanged;
                    }
                    db.SaveChanges();
                }
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
        public static void Eliminar(int id)
        {
            var         db = new EjemploDetalleDb();
            Estudiantes Es = db.Estudiantes.Find(id);

            db.Estudiantes.Remove(Es);
            db.SaveChanges();
        }
Beispiel #11
0
        public static void Eliminar(int id)
        {
            var    db = new EjemploDetalleDb();
            Grupos g  = db.Grupos.Find(id);

            db.Grupos.Remove(g);
            db.SaveChanges();
        }
        public static bool Eliminar(int id)
        {
            bool retorno = false;

            try
            {
                using (EjemploDetalleDb db = new EjemploDetalleDb())
                {
                    Productos user = (from c in db.Producto where c.ProductoId == id select c).FirstOrDefault();
                    db.Producto.Remove(user);
                    db.SaveChanges();
                    retorno = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
        public static bool Eliminar(int id)
        {
            bool retorno = false;

            try
            {
                using (EjemploDetalleDb db = new EjemploDetalleDb())
                {
                    Models.CotizacionesDetalles user = (from c in db.CotizacionDetalle where c.DetalleId == id select c).FirstOrDefault();
                    db.CotizacionDetalle.Remove(user);
                    db.SaveChanges();
                    retorno = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
        public static bool  Insertar(Estudiantes est)
        {
            bool retorno = false;

            try
            {
                var db = new EjemploDetalleDb();

                db.Estudiantes.Add(est);
                db.SaveChanges();
                db.Dispose();

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

            return(retorno);
        }