void Guardar()
 {
     if (txtEscuela.Text == "")
     {
         MessageBox.Show("Ingresa el nombre de la escuela");
     }
     else
     {
         if (txtDireccion.Text == "")
         {
             MessageBox.Show("Ingresa la direccion");
         }
         else
         {
             escuela esc = new escuela
             {
                 nombre     = txtEscuela.Text,
                 direccion  = txtDireccion.Text,
                 usuario_id = 1,
                 estatus    = "Activo"
             };
             BaseDatos.GetBaseDatos().escuelas.Add(esc);
             BaseDatos.GetBaseDatos().SaveChanges();
             MessageBox.Show("Registro exitoso");
         }
     }
 }
        public IHttpActionResult Putescuela(int id, escuela escuela)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != escuela.id)
            {
                return(BadRequest());
            }

            db.Entry(escuela).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!escuelaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private void cleanForm()
 {
     FormUtils.clearTextbox(textControls());
     rdbActivo.Checked   = true;
     rdbInactivo.Checked = false;
     btnAgregar.Text     = "Agregar";
     selectedEscuela     = null;
     errorProvider.Clear();
 }
 public Registrar_Escuela(escuela esc)
 {
     InitializeComponent();
     ide                   = esc.id_escuela;
     txtEscuela.Text       = esc.nombre;
     txtDireccion.Text     = esc.direccion;
     btnGuardar.Visibility = Visibility.Hidden;
     btnEditar.Visibility  = Visibility.Visible;
 }
        public IHttpActionResult Getescuela(int id)
        {
            escuela escuela = db.escuela.Find(id);

            if (escuela == null)
            {
                return(NotFound());
            }

            return(Ok(escuela));
        }
 private void fillSelectedData(escuela currentEsc)
 {
     txtNombre.Text = currentEsc.nombre;
     if (currentEsc.estado)
     {
         rdbActivo.Checked = true;
     }
     else
     {
         rdbInactivo.Checked = true;
     }
 }
        public IHttpActionResult Postescuela(escuela escuela)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.escuela.Add(escuela);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = escuela.id }, escuela));
        }
        public IHttpActionResult Deleteescuela(int id)
        {
            escuela escuela = db.escuela.Find(id);

            if (escuela == null)
            {
                return(NotFound());
            }

            db.escuela.Remove(escuela);
            db.SaveChanges();

            return(Ok(escuela));
        }
Example #9
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            escuela = await _context.escuela.FirstOrDefaultAsync(m => m.ID == id);

            if (escuela == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #10
0
 public Registro_Clientes(cliente cl, escuela esc)
 {
     InitializeComponent();
     Autocomplete();
     idc                      = cl.id_cliente;
     ide                      = esc.id_escuela;
     txtCliente.Text          = cl.nombre;
     txtPaterno.Text          = cl.ap_paterno;
     txtMaterno.Text          = cl.ap_materno;
     txtemail.Text            = cl.correoelectronico;
     txtTelefono.Text         = cl.telefono;
     autoEscuela.SearchText   = esc.nombre;
     btnGuardar.Visibility    = Visibility.Hidden;
     btnActualizar.Visibility = Visibility.Visible;
 }
        private void saveData()
        {
            escuela tempEsc = new escuela
            {
                nombre = txtNombre.Text,
                estado = rdbActivo.Checked
            };
            Operation <escuela> operation = escuelaController.addRecord(tempEsc);

            if (operation.State)
            {
                MessageBox.Show("Escuela agregada con éxito", "Éxito",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadTable();
                cleanForm();
            }
        }
 private void dgvEscuelas_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         int index = e.RowIndex;
         if (index >= 0)
         {
             selectedEscuela = escuelas[index];
             btnAgregar.Text = "Modificar";
             fillSelectedData(selectedEscuela);
         }
     }
     catch (Exception ex)
     {
         FormUtils.defaultErrorMessage(ex);
     }
 }
Example #13
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            escuela = await _context.escuela.FindAsync(id);

            if (escuela != null)
            {
                _context.escuela.Remove(escuela);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Start"));
        }
Example #14
0
        private void filterData()
        {
            string value = txtBuscar.Text;


            List <materia> tempMateria;

            if (cbxEscuela.SelectedIndex != -1)
            {
                escuela filtro = (escuela)cbxEscuela.SelectedItem;
                long    id     = filtro.id;
                tempMateria = new List <materia>();
                foreach (materia m in materias)
                {
                    if (m.idEscuela == id)
                    {
                        tempMateria.Add(m);
                    }
                }
                dgvMaterias.DataSource = tempMateria;
                materias = tempMateria;
            }

            if (!value.Equals(""))
            {
                tempMateria = new List <materia>();
                foreach (materia m in materias)
                {
                    if (m.nombre.ToLower().Contains(value))
                    {
                        tempMateria.Add(m);
                    }
                }
                dgvMaterias.DataSource = tempMateria;
                materias = tempMateria;
            }

            if (cbxEscuela.SelectedIndex == -1 && value.Equals(""))
            {
                loadTable();
            }
        }
        private void updateData(escuela currentEsc)
        {
            currentEsc.nombre = txtNombre.Text;
            currentEsc.estado = rdbActivo.Checked;

            Operation <escuela> operation = escuelaController.updateRecord(currentEsc);

            if (operation.State)
            {
                MessageBox.Show("Escuela actualizada con éxito", "Éxito",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadTable();
                cleanForm();
            }
            else
            {
                MessageBox.Show(operation.Error, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }