1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| [WebMethod]
[System.Web.Script.Services.ScriptMethod]
public CascadingDropDownNameValue[] Marque()
{
SqlConnection sqlCon = new SqlConnection();
string ConnectionStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
sqlCon.ConnectionString = ConnectionStr;
string req4 = "SELECT id_marque, nom_marque FROM critere_marque ORDER BY nom_marque";
SqlCommand sqlCom4 = new SqlCommand(req4, sqlCon);
sqlCon.Open();
SqlDataReader dr = sqlCom4.ExecuteReader();
List<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
while (dr.Read())
{
l.Add(new CascadingDropDownNameValue(dr["nom_marque"].ToString(),
dr["id_marque"].ToString()));
}
sqlCon.Close();
sqlCom4.Dispose();
return l.ToArray();
}
[WebMethod]
[System.Web.Script.Services.ScriptMethod]
public CascadingDropDownNameValue[] Modele(string knownCategoryValues, string category)
{
string[] _categoryValues = knownCategoryValues.Split(':', ';');
string marqueId = _categoryValues[1];
SqlConnection sqlCon = new SqlConnection();
string ConnectionStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
sqlCon.ConnectionString = ConnectionStr;
string req6 = "SELECT id_modele, nom_modele FROM critere_modele WHERE id_marque = '" + marqueId + "' and archive=0 ORDER BY nom_modele";
SqlCommand sqlCom6 = new SqlCommand(req6, sqlCon);
sqlCon.Open();
SqlDataReader dr = sqlCom6.ExecuteReader();
List<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
while (dr.Read())
{
l.Add(new CascadingDropDownNameValue(dr["nom_modele"].ToString(),
dr["id_modele"].ToString()));
}
sqlCon.Close();
sqlCom6.Dispose();
return l.ToArray();
} |
Partager