一个关于天气预报的VS2010C#编程,如何把天气,风向转化为代码呢? 你所有的接收端都直接从google取天气不就行了么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我之前那个是GSM与PC通信,也就是GSM短信模块,可以么? 只知道可以用webservice做天气预报 用webservicehttp://www.webxml.com.cn/WebServices/WeatherWebService.asmx 不懂winform 如何实现。。 新手求学!不过如果是网站的话 我会使用 第3方提供的 api. 是啊,这个也是调用了API,但是我不知怎么把它的代码查出来。。 这个用数据库做挺好做的。1、天气、温度、风向 三个字段 建立对照表。2、根据数字编码 sql查询。3、override ToString()方法 解析成你自己想要的 protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text.Trim ()!= "") { DataClasses1DataContext context = new DataClasses1DataContext(); string[] str = new string[3]; str[0] = TextBox1.Text.Substring(0, 2); str[1] = TextBox1.Text.Substring(2, 3); str[2] = TextBox1.Text.Substring(5, 3); string str1 = ""; if (str[1].Substring(0, 1) == "1") { str1 = "温度:零下" + str[1].Substring (1)+"度"; } else { str1 = "温度:" + str[1].Substring(1) + "度"; } var linqdata = from table in context.天气情况 where table.编码 == str[0] select table.天气; var linqdata1 = from table in context.风向 where table.编码 == str[2] select table.风向1; Label1.Text = "天气:" + linqdata.ToList()[0] + " " + str1 + " " + "风向:" + linqdata1.ToList()[0]; } } static void codeToString() { string code= Console.ReadLine(); if (code.Trim()!= "") { DataClasses1DataContext context = new DataClasses1DataContext(); string[] str = new string[3]; str[0] = code.Substring(0, 2); str[1] = code.Substring(2, 3); str[2] = code.Substring(5, 3); string str1 = ""; if (str[1].Substring(0, 1) == "1") { str1 = "温度:零下" + str[1].Substring(1) + "度"; } else { str1 = "温度:" + str[1].Substring(1) + "度"; } var linqdata = from table in context.天气情况 where table.编码 == str[0] select table.天气; var linqdata1 = from table in context.风向 where table.编码 == str[2] select table.风向1; Console.WriteLine("天气:" + linqdata.ToList()[0] + " " + str1 + " " + "风向:" + linqdata1.ToList()[0]); Console.ReadLine(); } }DataClasses1DataContext 是Linq to sql classes. 数据库操作用这个简单方便 做成后台网站也可以。前台传入code码 后台转换完 返回字符串 Socket连接问题,困惑几天了! datagirdview改变值然后排序的问题 请求高手解答 关于图形控件,搞这方面的朋友可以看看或许能有帮助。 请教关于模拟PHP数组的问题 菜鸟问题,刚学编程 .net 启动线程界面比较卡的问题 求.net各版本的改动文档,谢谢 微信模拟登陆的时候有验证码的情况应该如何解决? C#Java痛苦的选择 读取mysql大对象报错(断言错误)的问题 一个关于向Word文档插数据的问题研究求教…大神请进
不过如果是网站的话 我会使用 第3方提供的 api.
1、天气、温度、风向 三个字段 建立对照表。
2、根据数字编码 sql查询。
3、override ToString()方法 解析成你自己想要的
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text.Trim ()!= "")
{
DataClasses1DataContext context = new DataClasses1DataContext();
string[] str = new string[3];
str[0] = TextBox1.Text.Substring(0, 2);
str[1] = TextBox1.Text.Substring(2, 3);
str[2] = TextBox1.Text.Substring(5, 3);
string str1 = "";
if (str[1].Substring(0, 1) == "1")
{
str1 = "温度:零下" + str[1].Substring (1)+"度";
}
else
{
str1 = "温度:" + str[1].Substring(1) + "度";
}
var linqdata = from table in context.天气情况
where table.编码 == str[0]
select table.天气;
var linqdata1 = from table in context.风向
where table.编码 == str[2]
select table.风向1;
Label1.Text = "天气:" + linqdata.ToList()[0] + " " + str1 + " " + "风向:" + linqdata1.ToList()[0];
}
}
{
string code= Console.ReadLine();
if (code.Trim()!= "")
{
DataClasses1DataContext context = new DataClasses1DataContext();
string[] str = new string[3];
str[0] = code.Substring(0, 2);
str[1] = code.Substring(2, 3);
str[2] = code.Substring(5, 3);
string str1 = "";
if (str[1].Substring(0, 1) == "1")
{
str1 = "温度:零下" + str[1].Substring(1) + "度";
}
else
{
str1 = "温度:" + str[1].Substring(1) + "度";
}
var linqdata = from table in context.天气情况
where table.编码 == str[0]
select table.天气;
var linqdata1 = from table in context.风向
where table.编码 == str[2]
select table.风向1;
Console.WriteLine("天气:" + linqdata.ToList()[0] + " " + str1 + " " + "风向:" + linqdata1.ToList()[0]);
Console.ReadLine();
}
}DataClasses1DataContext 是Linq to sql classes. 数据库操作用这个简单方便
前台传入code码 后台转换完 返回字符串