示例#1
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 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);
        }
示例#5
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);
        }
 public ActionResult Edit([Bind(Include = "ProductoId,Descripcion,Costo,Precio")] Productos productos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productos));
 }
示例#7
0
 public ActionResult Edit([Bind(Include = "ClienteId,Nombres")] Clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
 public ActionResult Edit([Bind(Include = "CotizacionId,Fecha,Monto,ClienteId")] Cotizaciones cotizaciones)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cotizaciones).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClienteId = new SelectList(db.Cliente, "ClienteId", "Nombres", cotizaciones.ClienteId);
     return(View(cotizaciones));
 }
 public ActionResult Edit([Bind(Include = "DetalleId,CotizacionId,ProductoId,Descripcion,Cantidad,Precio")] CotizacionesDetalles cotizacionesDetalles)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cotizacionesDetalles).State = EntityState.Modified;
         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));
 }