Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string[]      latlong  = new string[2];
            ConexionMySQL conexion = new ConexionMySQL(Datos);

            try
            {
                latlong = cargarLatitudLatitud(constructuirGeoURL(txtNumero.Text + "+" + txtCalle.Text + "+" + txtColonia.Text + "+" + txtCiudad.Text + "+" + txtEstado.Text));
                string Query = "INSERT INTO emergencias(calleEmergencia,coloniaEmergencia,numeroEmergencia,cpEmergencia,ciudadEmergencia,estadoEmergencia,entreCallesEmergencia,otrasReferenciasEmergencia,ubicacionEmergencia)" +
                               " VALUES(\"" + txtCalle.Text + "\",\"" + txtColonia.Text + "\"," + Convert.ToInt32(txtNumero.Text) + "," + Convert.ToInt32(txtCP.Text) + ",\"" + txtCiudad.Text + "\",\"" + txtEstado.Text + "\",\"" + txtEntreCalles.Text + "\",\"" + txtReferencias.Text + "\",\"" + latlong[0] + "," + latlong[1] + "\");";
                MySqlDataReader adapter = conexion.conexionSendData(Query);
                while (adapter.Read())
                {
                }
                conexion.conexionClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al Agregar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            txtCalle.Text       = "";
            txtCiudad.Text      = "";
            txtColonia.Text     = "";
            txtCP.Text          = "";
            txtEntreCalles.Text = "";
            txtEstado.Text      = "";
            txtNumero.Text      = "";
            txtReferencias.Text = "";
            obtenerFolio();
        }
        private bool checarConexion()
        {
            ConexionMySQL conexion = new ConexionMySQL(data);
            DataTable     datosRow = new DataTable();

            try
            {
                string           Query   = "SELECT COUNT(*) FROM emergency.ambulanciasdisponibles;";
                MySqlDataAdapter adapter = conexion.conexionGetData(Query);
                adapter.Fill(datosRow);
                if (datosRow.Rows.Count >= 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                conexion.conexionClose();
            }
        }
Exemplo n.º 3
0
        private void obtenerFolio()
        {
            ConexionMySQL conexion = new ConexionMySQL(Datos);

            try
            {
                string           Query   = "SELECT MAX(idEmergencia) FROM emergencias;";
                MySqlDataAdapter adapter = conexion.conexionGetData(Query);
                DataTable        datos   = new DataTable();
                adapter.Fill(datos);

                textBox9.Text = Convert.ToString((Convert.ToInt32(datos.Rows[0][0].ToString()) + 1));
                conexion.conexionClose();
            }
            catch (Exception ex)
            {
            }
        }