Exemple #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            float lat    = Convert.ToSingle(txtLat.Text);
            float lon    = Convert.ToSingle(txtLon.Text);
            float facing = Convert.ToSingle(txtFacing.Text);

            WeatherReport    wr = new WeatherReport(lat, lon, facing, DateTime.Now, -1);
            WeatherUtilities wu = new WeatherUtilities();

            wu.addWeatherReport(wr);
            clear();
        }
Exemple #2
0
        public void addWeatherReport(WeatherReport wr)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = conString;
            SqlCommand cmd = new SqlCommand("Insert Into reports (lat, lon, timesubmitted, facing) values(@lat, @lon, @datesubmitted, @facing)");

            cmd.Parameters.AddWithValue("lat", wr.Latitude);
            cmd.Parameters.AddWithValue("lon", wr.Longitude);
            cmd.Parameters.AddWithValue("datesubmitted", wr.DateSubmitted);
            cmd.Parameters.AddWithValue("facing", wr.Facing);

            cmd.Connection = con;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
        }