Exemplo n.º 1
0
 public static bool comprobarBusqueda(Centros pCentro, bool check)
 {
     if (String.IsNullOrEmpty(pCentro.Calle) && String.IsNullOrEmpty(pCentro.Ciudad))
     {
         check = false;
     }
     return(check);
 }
Exemplo n.º 2
0
 public bool comprobarTexto(Centros pCentro, bool check)
 {
     if (String.IsNullOrEmpty(pCentro.Calle) || String.IsNullOrEmpty(pCentro.Ciudad))
     {
         check = false;
     }
     return(check);
 }
Exemplo n.º 3
0
 public static int Altas(Centros pCentro, MySqlConnection conexion)
 {
     try
     {
         MySqlCommand comando = new MySqlCommand(string.Format("Insert into " + tabla + " (Ciudad,Calle) values ('{0}','{1}')", pCentro.Ciudad, pCentro.Calle), Conexion.ObtenerConexion(conexion));
         retorno = comando.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message);
     }
     finally
     {
         conexion.Close();
     }
     return(retorno);
 }
Exemplo n.º 4
0
 public static MySqlDataAdapter Buscar(Centros pCentro, MySqlConnection conexion, MySqlDataAdapter da)
 {
     try
     {
         MySqlCommand comando = new MySqlCommand(string.Format("SELECT * FROM  " + tabla + " WHERE Ciudad LIKE '%" + pCentro.Ciudad + "%' AND Calle LIKE '%" + pCentro.Calle + "%'"), Conexion.ObtenerConexion(conexion));
         da = new MySqlDataAdapter(comando);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         conexion.Close();
     }
     return(da);
 }
Exemplo n.º 5
0
        /*public static int BajasProfesores(Centros pCentro, MySqlConnection conexion)
         * {
         *  try
         *  {
         *      MySqlCommand comando = new MySqlCommand(string.Format("Delete from profesores WHERE Centros_idCentros = " + pCentro.IdCentro), Conexion.ObtenerConexion(conexion));
         *      retorno = comando.ExecuteNonQuery();
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageBox.Show("Error: " + ex.Message);
         *  }
         *  finally
         *  {
         *      conexion.Close();
         *  }
         *  return retorno;
         * }*/
        public static int Modificar(Centros pCentro, MySqlConnection conexion)
        {
            try
            {
                MySqlCommand comando = new MySqlCommand(string.Format("UPDATE " + tabla + " SET Ciudad = '" + pCentro.Ciudad + "', Calle = '" + pCentro.Calle + "'WHERE idcentros = " + pCentro.IdCentro), Conexion.ObtenerConexion(conexion));
                retorno = comando.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally {
                conexion.Close();
            }

            return(retorno);
        }
Exemplo n.º 6
0
 public static int Bajas(Centros pCentro, MySqlConnection conexion)
 {
     try
     {
         MySqlCommand comando = new MySqlCommand(string.Format("Delete from " + tabla + " WHERE idCentros =" + pCentro.IdCentro), Conexion.ObtenerConexion(conexion));
         retorno = comando.ExecuteNonQuery();
     }
     catch (MySqlException ex)
     {
         switch (ex.Number)
         {
         case 1451:
             MessageBox.Show("No puedes eliminar un centro que tiene profesores asignados");
             break;
         }
     }
     finally
     {
         conexion.Close();
     }
     return(retorno);
 }
Exemplo n.º 7
0
 public static MySqlDataAdapter Cargar(Centros pCentro, MySqlConnection conexion, MySqlDataAdapter da)
 {
     try
     {
         MySqlCommand comando = new MySqlCommand("select * from " + vista, Conexion.ObtenerConexion(conexion));
         da = new MySqlDataAdapter(comando);
     }
     catch (MySqlException ex)
     {
         switch (ex.Number)
         {
         case 1042:
             MessageBox.Show("No se pudo realizar la conexion con el servidor");
             break;
         }
     }
     finally
     {
         conexion.Close();
     }
     return(da);
 }