基本信息
源码名称:c#调用webservice服务几种方式(获取天气预报)
源码大小:0.22M
文件格式:.zip
开发语言:C#
更新时间:2018-02-08
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍


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

namespace cweather
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        } 
        private void button1_Click(object sender, EventArgs e)
        {
            int i = 0;
            cweather.webconn.WeatherWebService ws = new cweather.webconn.WeatherWebService();
            string[] r = ws.getWeatherbyCityName("贵阳");
            this.richTextBox1.Text = "";
            if (r == null)
            {
                this.richTextBox1.Text = "无"   this.richTextBox1.Text   "城市的天气信息";
                return;
            }
            foreach (string str in r)
            {
                i  ;
                this.richTextBox1.Text  = str;
                if (i == 9)
                {
                    string ls_path = @"E:\学习源码\C#\cweather\cweather\pic\"   str ;
                    pictureBox1.Image = Image.FromFile(ls_path);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {  
            string url = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=54511";
            string message1 = WebServiceHelper.CallServiceByGet(url);
            this.richTextBox2.Text = message1; 
        }


        private void button3_Click(object sender, EventArgs e)
        {
            string url = @"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName";
            string cityname = "theCityName=54511";

            string message = WebServiceHelper.CallServiceByPost(url, cityname);
            this.richTextBox3.Text = message; 
        } 
        private void Form1_Resize(object sender, EventArgs e)
        {
            richTextBox1.Width = this.Width - 40;
            richTextBox1.Height = (this.Height / 3) - 60;

            button2.Top = button1.Top   richTextBox1.Height   30;
            richTextBox2.Top = button1.Top   richTextBox1.Height   button2.Height   30;
            richTextBox2.Width = this.Width - 40;
            richTextBox2.Height = (this.Height / 3) - 60;


            button3.Top = button2.Top   richTextBox2.Height   30;
            richTextBox3.Top = button2.Top   richTextBox2.Height   button3.Height   30;
            richTextBox3.Width = this.Width - 40;
            richTextBox3.Height = (this.Height / 3) - 90;
        } 
        private void Form1_Load(object sender, EventArgs e)
        { 
            //this.Resize  = new EventHandler(Form1_Resize);//窗体调整大小时引发事件
        } 
        
    }
}