Esempio n. 1
0
 public ActionResult Edit([Bind(Include = "IdChofer,NroDoc,Nombres,Apellidos,NroTelefono,NroLicencia,CateLicencia")] Chofer chofer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chofer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(chofer));
 }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "IdPerfil,IdPuesto,Nombre,Descripcion,Competencias,Caracteristicas,SueldoIni,SueldoFin,Estado")] Perfil perfil)
 {
     if (ModelState.IsValid)
     {
         db.Entry(perfil).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdPuesto = new SelectList(db.Puesto, "IdPuesto", "Nombre", perfil.IdPuesto);
     return(View(perfil));
 }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "IdOfertaLaboral,Titulo,IdPerfil,IdSucursal,FuncionesAdicionales,TiempoValidez,FechaCrea,Estado")] OfertaLaboral ofertalaboral)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ofertalaboral).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdPerfil   = new SelectList(db.Perfil, "IdPerfil", "Nombre", ofertalaboral.IdPerfil);
     ViewBag.IdSucursal = new SelectList(db.Sucursal, "IdSurcursal", "Nombre", ofertalaboral.IdSucursal);
     return(View(ofertalaboral));
 }
        public string GuardarNota(NotaIngreso nota)
        {
            if (nota.NumeroNotaIngreso == null)
            {
                var    ultimo = db.NotaIngreso.OrderByDescending(x => x.NumeroNotaIngreso).Take(1).FirstOrDefault();
                double numero = 1;
                if (ultimo != null)
                {
                    numero = double.Parse(ultimo.NumeroNotaIngreso.Replace("NI-", "")) + 1;
                }
                nota.NumeroNotaIngreso = "NI-" + double.Parse(numero.ToString()).ToString("#000000");

                db.NotaIngreso.Add(nota);

                //Agregamos un movimiento al Kardex
                Kardex objKardex;
                List <DetalleKardex> detalleKardex = new List <DetalleKardex>();
                DetalleKardex        dKardex;

                foreach (var item in nota.DetalleNotaIngreso)
                {
                    //Detalle del kardex
                    objKardex = db.Kardex.FirstOrDefault(x => x.IdProducto == item.IdProducto); //&& x.IdAlmacen == IdAlmacen
                    if (objKardex != null)
                    {
                        dKardex = new DetalleKardex();
                        dKardex.NumeroKardex      = objKardex.NumeroKardex;
                        dKardex.NumeroDocumento   = nota.NumeroOrdenCompra;
                        dKardex.TipodeMovimiento  = 1;
                        dKardex.NumeroNotaIngreso = nota.NumeroNotaIngreso;
                        dKardex.Fecha             = DateTime.Now;
                        dKardex.Cantidad          = item.Cantidad;
                        detalleKardex.Add(dKardex);
                    }
                }

                db.DetalleKardex.AddRange(detalleKardex);
            }
            else
            {
                var original = db.NotaIngreso.Find(nota.NumeroNotaIngreso);
                if (original != null)
                {
                    db.Entry(original).CurrentValues.SetValues(nota);

                    ////Ya no actualiza los items, porque tendría que modificar el kardex también

                    //db.DetalleNotaIngreso.RemoveRange(db.DetalleNotaIngreso.Where(x => x.NumeroNotaIngreso == nota.NumeroNotaIngreso));
                    //db.SaveChanges();

                    //DetalleNotaIngreso obj;

                    //foreach (var item in nota.DetalleNotaIngreso)
                    //{
                    //    obj = new DetalleNotaIngreso();
                    //    obj.Cantidad = item.Cantidad;
                    //    obj.IdProducto = item.IdProducto;
                    //    obj.NumeroNotaIngreso = item.NumeroNotaIngreso;

                    //    db.DetalleNotaIngreso.Add(obj);
                    //}
                }
            }

            db.SaveChanges();
            return(nota.NumeroNotaIngreso);
        }