Esempio n. 1
0
        public List <SedeModel> ListarSedes()
        {
            List <SedeModel> sedes = new List <SedeModel>();

            using (ConnectionSQL = new SqlConnection(ConnectionDB))
            {
                using (CmdSQL = new SqlCommand("Usp_obtenerSedes", ConnectionSQL))
                {
                    CmdSQL.CommandType = CommandType.StoredProcedure;
                    CmdSQL.Connection.Open();
                    AdapterSQL = new SqlDataAdapter(CmdSQL);
                    TablesSQL  = new DataTable();
                    AdapterSQL.Fill(TablesSQL);

                    ReaderSQL = CmdSQL.ExecuteReader();

                    while (ReaderSQL.Read())
                    {
                        SedeModel SedeData = new SedeModel
                        {
                            SedeID          = (int)ReaderSQL["Sede ID"],
                            NombreSede      = ReaderSQL["Sede"].ToString(),
                            NumeroComplejos = (int)ReaderSQL["Complejos"],
                            Presupuesto     = (decimal)ReaderSQL["Presupuesto"]
                        };

                        sedes.Add(SedeData);
                    }
                }
            }

            return(sedes);
        }
 public ActionResult EditarSede(SedeModel sedeModel, int id)
 {
     try
     {
         sedeBL = new SedesBL();
         sedeBL.EditarSede(sedeModel);
         return(RedirectToAction("Sedes"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 3
0
 public ActionResult EliminarComplejo(int id, SedeModel sedeModel)
 {
     try
     {
         complejoBL = new ComplejoBL();
         if (complejoBL.DeleteComplejo(id) >= 1)
         {
             ViewBag.AlertMsg = "Complejo eliminado";
         }
         return(RedirectToAction("Complejos"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult EliminarSede(int id, SedeModel sedeModel)
 {
     try
     {
         sedeBL = new SedesBL();
         if (sedeBL.DeleteSede(id) >= 1)
         {
             ViewBag.AlertMsg = "Empleado eliminado";
         }
         return(RedirectToAction("Sedes"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 5
0
        public ActionResult nuevaSede(SedeModel s)
        {
            if (ModelState.IsValid)
            {
                Sede sede = new Sede();
                sede.Direccion     = s.Direccion;
                sede.Nombre        = s.Nombre;
                sede.PrecioGeneral = s.PrecioGeneral;

                sMng.agregarSede(sede);
                TempData["Mjs"] = "La Sede " + s.Nombre + " ha sido agregada Correctamente";
                return(RedirectToAction("Sedes", "Sedes"));
            }

            TempData["Mensaje"] = "Ha ocurrido un error al insertar la sede";

            return(RedirectToAction("nuevaSede", "Sedes"));
        }
Esempio n. 6
0
        public int RegistrarSede(SedeModel sedeModel)
        {
            int Result = -1;

            using (ConnectionSQL = new SqlConnection(ConnectionDB))
            {
                using (CmdSQL = new SqlCommand("Usp_AgregaSede", ConnectionSQL))
                {
                    CmdSQL.CommandType = CommandType.StoredProcedure;
                    CmdSQL.Parameters.Add("@NombreSede", SqlDbType.NVarChar, 20).Value = sedeModel.NombreSede;
                    CmdSQL.Parameters.Add("@NroComplejos", SqlDbType.Int).Value        = sedeModel.NumeroComplejos;
                    CmdSQL.Parameters.Add("@Presupuesto", SqlDbType.Decimal).Value     = sedeModel.Presupuesto;
                    CmdSQL.Connection.Open();

                    Result = CmdSQL.ExecuteNonQuery();
                }
            }

            return(Result);
        }
        public ActionResult CrearSede(SedeModel sedeModel)
        {
            var m = 0;

            try
            {
                if (ModelState.IsValid)
                {
                    sedeBL = new SedesBL();

                    if (sedeBL.RegistrarSede(sedeModel) >= 1)
                    {
                        ViewBag.Message = "Sede registrada";
                        ModelState.Clear();
                    }
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }