protected void ddlVilles_SelectedIndexChanged(object sender, EventArgs e) { try { GlobalWeather service = new GlobalWeather(); string Data = service.GetWeather(ddlVilles.Text, ddlPays.Text); XElement Temp = XElement.Load(new System.IO.StringReader(Data)); string chaine = Temp.Value; // ---------------------- Determine le nombre d'espace --------------------- string[] res = chaine.Split(' '); // --- Recupere la valeur entre l'espace 14 et 13 en partant de la fin ---- string FMax = res[res.Length - 14]; // temperature Max string FMin = res[res.Length - 10]; // temperature Min //string directionVent = res[res.Length - 29]; // direction vent //string vitesseVent = res[res.Length - 25]; // vitesse vent string humidite = res[res.Length - 6]; // humidite de l'air string presure = res[res.Length - 5]; // pression // ------------------ Convertie la valeur String en Double ----------------- double a = double.Parse(FMax); double b = double.Parse(FMin); // -------------------- Convertie la valeur F en Celcus C ------------------ double CMax0 = (a - 32) * 5 / 9; double CMin0 = (b - 32) * 5 / 9; double CMax = Math.Round(CMax0, 0); // temperature Max double CMin = Math.Round(CMin0, 0); // temperature Min // ------------------------------- RESULTAT -------------------------------- lblTemperatureMax.Text = "Max : " + FMax + " F " + "(" + CMax + " C)"; lblTemperatureMin.Text = "Min : " + FMin + " F " + "(" + CMin + " C)"; //lblDirection.Text = "Direction : " + directionVent; //lblVitesse.Text = "Wind : " + vitesseVent + " MPH"; lblHumidite.Text = "Humidity : " + humidite; lblPrecipitation.Text = "Presure : " + presure + "''"; } catch { lblTemperatureMax.Text = "PLEASE TRY"; lblTemperatureMin.Text = "AGAIN LATER"; //lblDirection.Text = "Direction : " + directionVent; //lblVitesse.Text = "Wind : " + vitesseVent + " MPH"; lblHumidite.Text = "PLEASE TRY"; lblPrecipitation.Text = "AGAIN LATER"; } // lblTemperatureMax.Text = Temp.Value; }
private void GetWeather() { GlobalWeather gw = new GlobalWeather(); string result = gw.GetWeather(DropDownList2.SelectedItem.Text, DropDownList1.SelectedItem.Text); string[] res = GetStringInBetween(result); Label1.Text = "Temperature : " + res[0]; }
private void GetWeather() { GlobalWeather gw = new GlobalWeather(); string result = gw.GetWeather(ddlCity.SelectedItem.Text, ddlCountry.SelectedItem.Text); string[] res = GetStringInBetween(result); lblTemp1.Text = "Temperature : " + res[0]; }
protected void Page_Load(object sender, EventArgs e) { GlobalWeather gw = new GlobalWeather(); Label1.Text = gw.GetWeather("lucknow", "india"); DropDownList1.DataSource = gw.GetCitiesByCountry("india"); DropDownList1.DataBind(); GridView1.DataSource = gw.GetCitiesByCountry("pakistan"); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //Ensure that the code executes only when the page loads if (!IsPostBack) { try { //captures the user long id lblClientNumber.Text = Page.User.Identity.Name; //parse the login clientnumber to integer int clientNumber = int.Parse(Page.User.Identity.Name.ToString()); //Store this clientNumber value in a Session variable Session["ClientNumber"] = clientNumber; //lambda used to return the clientID int clientId = db.Clients.Where(record => record.ClientNumber == clientNumber).Select(record => record.ClientId).Single(); //Store this ClientId value in a Session variable Session["ClientId"] = clientId; //Define a LINQ-to-SQL Server query object with all records from the BankAccount table whose ClientID matches the ClientID retrieved in the previous step IQueryable <BankOfBIT.Models.BankAccount> query = db.BankAccounts.Where(record => record.ClientId == clientId); //binding the data gvAccounts.DataSource = query.ToList(); //mutiple controls option this.DataBind(); //add for assignment5 exchange lbl GlobalWeather weather = new GlobalWeather(); lblExchangeRate.Text = weather.GetWeather("Winnipeg", "Canada"); } //If an exception occurs during this routine, display an appropriate message in the Message label at the bottom of the form catch (Exception) { lblWarnings.Text = "Something went wrong trying to load the data"; } } }