Esempio n. 1
0
        public void Municipio(string id_Estado)
        {
            CONEXION_ESTADOS con = new CONEXION_ESTADOS();

            con.CONEXION.Open();
            string mysql = "SELECT id_municipio,municipio FROM t_municipio where id_Estado='" + id_Estado + "' order by municipio ";

            txtMunicipio.DataSource = null;
            txtMunicipio.Items.Clear();
            try
            {
                MySqlCommand     select1 = new MySqlCommand(mysql, con.CONEXION);
                MySqlDataAdapter reader  = new MySqlDataAdapter(select1);
                DataTable        tabla   = new DataTable();
                DataRow          fila    = tabla.NewRow();
                reader.Fill(tabla);
                fila["municipio"] = "Seleccione un Municipio";
                tabla.Rows.InsertAt(fila, 0);
                txtMunicipio.ValueMember   = "id_municipio";
                txtMunicipio.DisplayMember = "municipio";
                txtMunicipio.DataSource    = tabla;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrio un error: " + ex);
            }
            finally
            {
                con.CONEXION.Close();
            }
        }
Esempio n. 2
0
        public void Estado()
        {
            CONEXION_ESTADOS con = new CONEXION_ESTADOS();

            con.CONEXION.Open();
            string mysql = "SELECT*from t_estado order by estado";

            txtEstado.DataSource = null;
            txtEstado.Items.Clear();
            try
            {
                MySqlCommand     select = new MySqlCommand(mysql, con.CONEXION);
                MySqlDataAdapter reader = new MySqlDataAdapter(select);
                DataTable        tabla  = new DataTable();
                DataRow          FILA   = tabla.NewRow();
                reader.Fill(tabla);
                FILA["estado"] = "Seleccione un estado";
                tabla.Rows.InsertAt(FILA, 0);
                txtEstado.ValueMember   = "id_estado";
                txtEstado.DisplayMember = "estado";
                txtEstado.DataSource    = tabla;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrio un error de tipo: " + ex);
            }
            finally
            {
                con.CONEXION.Close();
            }
        }