• 大小: 161KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-15
  • 语言: C#
  • 标签: C#  查天气  

资源简介

C# 调用天气预报的webservice查询实时天气。。。vs2015开发的winform程序。简单操作。供新手学习。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace WebService
{
    public partial class frmMain : Form
    {
        WeatherWebService.WeatherWebService weather = new WeatherWebService.WeatherWebService();
        public frmMain()
        {
            InitializeComponent();
            LoadProvince(); //加载省份                            
        }

        private void LoadProvince()
        {
            string[] province = weather.getSupportProvince();
            foreach (string item in province)
            {
                cmbProvince.Items.Add(item);
            }
        }

        private void cmbProvince_TextChanged(object sender EventArgs e)
        {
            cmbCity.SelectedIndex = -1;
            cmbCity.Items.Clear();
            string[] citys = weather.getSupportCity(cmbProvince.Text);
            foreach (string item in citys)
            {
                string[] city = item.Split(‘ ‘);
                cmbCity.Items.Add(city[0]);
            }
        }

        private void cmbCity_TextChanged(object sender EventArgs e)
        {
            string[] weather = new string[23];
            weather = this.weather.getWeatherbyCityName(cmbCity.Text.Trim());
            if (weather[8] == ““)
            {
                MessageBox.Show(“暂时不支持您查询的城市“);
            }
            else
            {
                lblSurvey.Text = weather[1] + “ “ + weather[6] + “ 最低/最高气温: “ + weather[5];
                txtRealTime.Text = weather[10] + “\r\n“ + “城市简介: “ + weather[22];
            }

        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-16 15:34  WebService\
     文件        2060  2018-01-15 11:50  WebService\App.config
     目录           0  2018-04-16 15:01  WebService\bin\
     目录           0  2018-04-16 15:35  WebService\bin\Debug\
     文件       23040  2018-04-16 15:35  WebService\bin\Debug\WebService.exe
     文件        2060  2018-01-15 11:50  WebService\bin\Debug\WebService.exe.config
     文件       42496  2018-04-16 15:35  WebService\bin\Debug\WebService.pdb
     文件       21680  2018-04-16 15:35  WebService\bin\Debug\WebService.vshost.exe
     文件        2060  2018-01-15 11:50  WebService\bin\Debug\WebService.vshost.exe.config
     目录           0  2018-04-16 15:35  WebService\bin\Release\
     文件       22016  2018-04-16 15:35  WebService\bin\Release\WebService.exe
     文件        2060  2018-01-15 11:50  WebService\bin\Release\WebService.exe.config
     文件       40448  2018-04-16 15:35  WebService\bin\Release\WebService.pdb
     文件       21680  2018-04-16 15:35  WebService\bin\Release\WebService.vshost.exe
     文件        2060  2018-01-15 11:50  WebService\bin\Release\WebService.vshost.exe.config
     文件         490  2015-10-22 09:54  WebService\bin\Release\WebService.vshost.exe.manifest
     文件       23040  2018-04-16 15:35  WebService\bin\Release\WebService.xmlSerializers.dll
     文件        1829  2018-04-16 15:34  WebService\frmMain.cs
     文件        6771  2018-04-16 15:22  WebService\frmMain.Designer.cs
     文件        5817  2018-04-16 15:22  WebService\frmMain.resx
     目录           0  2018-01-09 10:10  WebService\obj\
     目录           0  2018-04-16 15:35  WebService\obj\Debug\
     文件        1482  2017-12-20 17:49  WebService\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        8067  2018-04-16 15:35  WebService\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2017-12-20 17:21  WebService\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2017-12-20 17:21  WebService\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2017-12-20 17:21  WebService\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2017-12-20 17:49  WebService\obj\Debug\TempPE\
     文件        4096  2017-12-20 17:55  WebService\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
     文件        5120  2017-12-20 17:55  WebService\obj\Debug\TempPE\Service References.WeatherService.Reference.cs.dll
     文件       13312  2018-01-15 10:01  WebService\obj\Debug\TempPE\Web References.WeatherWebService.Reference.cs.dll
............此处省略43个文件信息

评论

共有 条评论