Exemplo n.º 1
0
        private void timer_weatherQuery_Tick(object state, EventArgs sender)//查询天气
        {
            WeatherClass  WC     = new WeatherClass();
            WeatherDetail detail = new WeatherDetail();

            if (WC.WeatherQuery(Client.ConfigClass.getInstance().getValue("province"), Client.ConfigClass.getInstance().getValue("city"), out detail))
            {
                WeatherUpdate.update(detail);
            }
            else
            {
                this.LB_NetState.Text      = "异常";
                this.LB_NetState.ForeColor = Color.Red;
            }
        }
Exemplo n.º 2
0
 private void Btn_Confirm_Click(object sender, EventArgs e)
 {
     if (this.dateTime.Value != null && this.cbo_weather.Text != null && this.tbo_temperature.Text != null && this.tbo_wind.Text != null)
     {
         float temperature;
         if (float.TryParse(this.tbo_temperature.Text, out temperature))
         {
             DateTime           dt        = this.dateTime.Value;
             string             weather   = this.cbo_weather.Text.ToString();
             string             wind      = this.tbo_wind.Text;
             Client.MySqlHelper mysql     = new Client.MySqlHelper();
             string             sqlString = string.Format("INSERT INTO tb_weather SET time='{0}',weather='{1}',temperature={2},wind='{3}';", dt, weather, temperature, wind);
             try
             {
                 mysql.ExecuteNonQuery(sqlString);
                 WeatherDetail detail = new WeatherDetail();
                 detail.weather             = new Weather();
                 detail.wind                = new Wind();
                 detail.publish_time        = dt.ToString();
                 detail.weather.temperature = temperature;
                 detail.wind.power          = wind;
                 detail.weather.info        = weather;
                 WeatherUpdate.update(detail);
                 this.tbo_temperature.Text = "";
                 this.tbo_wind.Text        = "";
                 this.cbo_weather.Text     = "";
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 MessageBox.Show("写入数据库失败");
             }
         }
         else
         {
             MessageBox.Show("请输入正确温度");
         }
     }
     else
     {
         MessageBox.Show("请输入全部信息");
     }
 }
Exemplo n.º 3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            timer.Tick                 += timer_Tick;
            timer.Interval              = 1000;
            timer_weatherQuery.Tick    += timer_weatherQuery_Tick;
            timer_weatherQuery.Interval = 1800000;
            timer_weatherQuery.Start();

            timer_check.Tick    += timer_check_Tick;
            timer_check.Interval = 60000;
            //按比例调节各空间位置和大小
            XProportion = (double)this.Size.Width / (double)1366;
            YProportion = (double)this.Size.Height / (double)768;
            operation.ChangeWindowsSize(this, XProportion, YProportion);
            //获取天气
            WeatherUpdate.LB_NetState  = this.LB_NetState;
            WeatherUpdate.LB_Tem       = this.LB_Tem;
            WeatherUpdate.LB_Weather   = this.LB_Weather;
            WeatherUpdate.LB_WindPower = this.LB_WindPower;
            WeatherUpdate.Pic_Weather  = this.Pic_Weather;
            WeatherUpdate.readWeatherDetail();
        }