public List <Estado_Mdl> ListaEstado(string Servidor, int idPais) { List <Estado_Mdl> listaestado = new List <Estado_Mdl>(); SqlConnection cnObj = new SqlConnection(); cnObj = objConexion.Conectar_Master(Servidor); if (cnObj != null) { using (cnObj) { SqlCommand cmdObj = new SqlCommand(); cmdObj.Connection = cnObj; string strSql; strSql = "SELECT "; strSql += "id_estado, "; strSql += "id_pais, "; strSql += "estado "; strSql += "FROM "; strSql += "estado "; strSql += "WHERE "; strSql += "id_pais = " + idPais + ""; cmdObj.CommandText = strSql; SqlDataReader rdrObj = cmdObj.ExecuteReader(); while (rdrObj.Read()) { Estado_Mdl objEstado = new Estado_Mdl(); objEstado.id_estado = Convert.ToInt32(rdrObj[0].ToString()); objEstado.id_pais = Convert.ToInt32(rdrObj[1].ToString()); objEstado.estado = rdrObj[2].ToString(); listaestado.Add(objEstado); } rdrObj.Close(); } } return(listaestado); }
public List <Estado_Mdl> EstadoSeleccionado(int idPais, int idEstado) { List <Estado_Mdl> listaestados = new List <Estado_Mdl>(); MySqlConnection cnObj = new MySqlConnection(); cnObj = objConexion.Conectar(); if (cnObj != null) { MySqlCommand cmdObj = new MySqlCommand(); cmdObj.Connection = cnObj; string strSql; strSql = "SELECT "; strSql += "id_estado, "; strSql += "id_pais, "; strSql += "estado "; strSql += "FROM "; strSql += "estado "; strSql += "WHERE "; strSql += "id_pais = '" + idPais + "' AND "; strSql += "id_estado = " + idEstado + ""; cmdObj.CommandText = strSql; MySqlDataReader rdrObj = cmdObj.ExecuteReader(); while (rdrObj.Read()) { Estado_Mdl objEstado = new Estado_Mdl(); objEstado.id_estado = rdrObj[0].ToString(); objEstado.id_pais = rdrObj[1].ToString(); objEstado.estado = rdrObj[2].ToString(); listaestados.Add(objEstado); } rdrObj.Close(); cnObj.Close(); } return(listaestados); }