Ejemplo n.º 1
0
 private void btnCrear_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtNombre.Text) || string.IsNullOrEmpty(txtDescripcion.Text))
     {
         MessageBox.Show("Datos erroneos", "Departamento", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DepartamentoLogica logica = new DepartamentoLogica();
         Departamento       nuevo  = logica.CrearDepartamento(txtNombre.Text, txtDescripcion.Text);
         if (nuevo == null)
         {
             MessageBox.Show("Departamento ya existe", "Departamento", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtNombre.Text      = "";
             txtDescripcion.Text = "";
         }
         else
         {
             MessageBox.Show("Departamento " + nuevo.Nombre_departamento + " fue creado", "Departamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //AdminMenu menu = new AdminMenu(usuario);
             //menu.Show();
             listaDepartamentosTableAdapter1.Fill(conexionUsuarios1.ListaDepartamentos);
             txtNombre.Text      = "";
             txtDescripcion.Text = "";
         }
     }
 }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            DepartamentoLogica cl = new DepartamentoLogica();

            cl.EliminarDepartamento(id);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        // GET: Departamentos
        public ActionResult Index()
        {
            var logica  = new DepartamentoLogica();
            var listado = logica.GetListadoDepartamentos();

            return(View(listado));
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Id,NombreDepartamento,PaisId")] DepartamentoModelo departamentoModelo)
 {
     if (ModelState.IsValid)
     {
         DepartamentoLogica cl = new DepartamentoLogica();
         cl.EditarDepartamento(departamentoModelo);
         return(RedirectToAction("Index"));
     }
     return(View(departamentoModelo));
 }
Ejemplo n.º 5
0
 public ActionResult Delete(int id, DepartamentoModel dept)
 {
     try
     {
         var logica = new DepartamentoLogica();
         logica.eliminarDept(id, dept);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
 public ActionResult Edit(int id, DepartamentoModel dept)
 {
     try
     {
         var logica = new DepartamentoLogica();
         logica.editarPais(id, dept);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 7
0
 public ActionResult Create(DepartamentoModel dept)
 {
     try
     {
         var logica = new DepartamentoLogica();
         logica.agregarDept(dept);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 8
0
        // GET: Departamentos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DepartamentoModelo departamentoModelo = new DepartamentoLogica().EditarDepartamento(id);

            if (departamentoModelo == null)
            {
                return(HttpNotFound());
            }
            return(View(departamentoModelo));
        }
Ejemplo n.º 9
0
        //Get: Pais/Departamentos/5
        public ActionResult Departamentos(int id)
        {
            var logDept = new DepartamentoLogica();

            return(View(logDept.getDepartamentoXPais(id)));
        }
Ejemplo n.º 10
0
        // GET: Departamento/Delete/5
        public ActionResult Delete(int id)
        {
            var logica = new DepartamentoLogica();

            return(View(logica.obtenerDept(id)));
        }