WinCE下的数据源操作以及天气软件的制作
WinCE下的数据源操作以及天气软件的制作
项目一 数据源显示
实验目标
本实验项目介绍如何利用DataGird控件显示数据库数据 技术要点
DataGird控件的使用,添加SqlServerCe引用,配置数据源 实验步骤
1. 首先,运行visual studio2005,创建名为“数据显示”的智能设备应用程序。 2. 右键单击“数据显示”解决方案,执行“添加引用”,如下图在“.NET”选项卡中选择;“System.Data.SqlServerCe”
3. 在窗体的代码视图中添加
using System.Data.SqlServerCe;
4.在窗体设计视图,打开“数据”菜单,执行“添加数据源…”, 如下图所示,选择“数据库”,单击“下一步”,在新对话框中单击“新建连接…”,在“添加连接”对话框中设置“数据源”为“我的电脑”,“数据库”为“C:\Program
Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0
WinCE下的数据源操作以及天气软件的制作
\Northwind.sdf”,并测试数据库连接;测试成功后,将数据文件复制到当前工程,并选中数据表。
5.执行“数据”菜单中的显示数据源,将Categories表拖动到窗体中,自动生成categoriesDataGird控件,右键单击数据网格右上角小箭头,执行“生成数据窗体”,设置“dock”属性为“top”
6. 将Products表拖入窗体中,自动生成productsDataGird控件,设置“dock”属性为“bottom”,
WinCE下的数据源操作以及天气软件的制作
项目二 SQLITE数据库操作
实验目标
本实验项目介绍数据库操作的编程方法。 技术要点
查询、插入、删除、更新数据库 实验步骤
1. 首先,运行visual studio2005,创建名为“数据显示”的智能设备应用程序
2. 添加天气源引用:
( ); 3. 安装sqlite,并添加引用; 4. 如图添加窗体控件:
5. 为按钮添加事件:
public partial class Form1 : Form {
WinCE下的数据源操作以及天气软件的制作
public Form1() {
InitializeComponent(); }
string dbPath = "/program files/weatherDB.db";
private string[] array = new string[23]; //数组存放从网络服务器获得的数据 private Bitmap MyImage;
//初始化,禁用按键
private void Form1_Load(object sender, EventArgs e) {
this.button1.Enabled = false; this.button2.Enabled = false; this.button3.Enabled = false; this.bReadDB.Enabled = false;
this.Text = "基于WINCE的天气信息终端"; }
//显示图像
public void ShowMyImage(String fileToDisplay, int xSize, int ySize) {
if (MyImage != null) {
MyImage.Dispose(); }
// 扩展图像到picturebox
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; MyImage = new Bitmap(fileToDisplay);
pictureBox1.ClientSize = new Size(xSize, ySize); pictureBox1.Image = (Image)MyImage; }
private void callWeatherService() //建立连接,从服务器获取数据 {
string weatherCityName;
weatherCityName = this.textBox1.Text.ToString();
http://doc.guandang.net.webxml.www.WeatherWebService weatherWS = new WeatherWebService(); array = weatherWS.getWeatherbyCityName(weatherCityName); }
private void showTodayWeather()//当天天气 {
WinCE下的数据源操作以及天气软件的制作
//#region MyRegion
this.lProvince.Text = array[0]; this.lCity.Text = array[1]; label1.Text = "今日天气实况:"; http://doc.guandang.netbel3.Text = array[6]; http://doc.guandang.netbel4.Text = array[5]; http://doc.guandang.netbel5.Text = array[7];
ShowMyImage("/Program Files/weatherpic/" + array[8], 70, 65);
//#endregion }
private void showTomorrowWeather()//明天天气 {
// #region MyRegion
label1.Text = "明日天气实况:"; http://doc.guandang.netbel3.Text = array[13]; http://doc.guandang.netbel4.Text = array[12]; http://doc.guandang.netbel5.Text = array[14];
ShowMyImage("/Program Files/weatherpic/" + array[15], 70, 65); // #endregion }
private void showDayAfterTomWeather()//后天天气 {
//#region MyRegion
label1.Text = "后天天气实况:"; http://doc.guandang.netbel3.Text = array[18]; http://doc.guandang.netbel4.Text = array[17]; http://doc.guandang.netbel5.Text = array[19];
ShowMyImage("/Program Files/weatherpic/" + array[20], 70, 65); //#endregion }
private void button1_Click(object sender, EventArgs e) {
showTodayWeather(); }
private void button2_Click(object sender, EventArgs e) {
showTomorrowWeather(); }
WinCE下的数据源操作以及天气软件的制作
private void button3_Click(object sender, EventArgs e) {
showDayAfterTomWeather(); }
private void bSetCity1_Click(object sender, EventArgs e) {
this.textBox1.Text = "广州"; this.bSetCity1.Text = "查询中..."; callWeatherService(); showTodayWeather(); getFromSer();
this.bSetCity1.Text = "广州";
this.button1.Enabled = true; this.button2.Enabled = true; this.button3.Enabled = true; //this.bReadDB.Enabled = true; }
private void bSetCity2_Click(object sender, EventArgs e) {
this.textBox1.Text = "中山"; this.bSetCity2.Text = "查询中..."; callWeatherService(); showTodayWeather(); getFromSer();
this.bSetCity2.Text = "中山";
this.button1.Enabled = true; this.button2.Enabled = true; this.button3.Enabled = true; //this.bReadDB.Enabled = true; }
private void bReadDB_Click(object sender, EventArgs e) {
readDB();
this.button1.Enabled = true; this.button2.Enabled = true; this.but …… 此处隐藏:5603字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [求职职场]加法运算定律的运用练习题
- [求职职场]大型石油化工工业过程节能新技术
- [求职职场]2015-2020年中国箱纸板行业分析与投资
- [求职职场]NADEX-IWC5A点焊机故障代码
- [求职职场]英语阅读 非常有用
- [求职职场]鲁卫疾控发〔2012〕2号(联合,印发山东
- [求职职场]2014年莆田公务员行测技巧:数字推理的
- [求职职场]基于最近发展区理论的高中数学课堂有效
- [求职职场]与贸易有关的知识产权协议
- [求职职场]【王风范】微演说·职场演说三
- [求职职场]新时代国珍健康大课堂
- [求职职场]群论期末考试复习题
- [求职职场]施工现场消防安全专项施工方案(范本)-
- [求职职场]初中物理光学知识点归纳完美版
- [求职职场]毕业设计总结与体会范文
- [求职职场]江南大学2018年上半年展示设计第1阶段
- [求职职场]景尚乡民兵参战支前保障方案
- [求职职场]【优质】2019年工会职工之家建设工作总
- [求职职场]数据库技术与应用—SQL Server 2008(第
- [求职职场]汽车变速箱构造与工作原理
- 首钢工业区工业遗产资源保护与再利用研
- 第4课 《大学》节选
- 2016程序文件——检验检测结果发布程序
- 2011年高考试题文言文阅读全解释__2011
- 化学是一门基础的自然科学
- 海外做市商制度的借鉴意义
- 外国建筑史复习资料(
- 七年级下思想品德期末综合测试(二)
- 思政课部2013年上学期教学工作总结
- 电大国际公法任务3 0004
- 《圆的认识》教学设计
- 中国轨道交通牵引变流器行业市场发展调
- 中泰证券#定期报告:坚守时代硬科技和
- 浅论企业财务管理与企业经营投资风险的
- 大功率半导体激光器光纤耦合技术调研报
- 中国传统家具的现状与发展探讨
- Broadcom数字电视芯片助海尔扩展高清电
- 新HSK4词汇练习 超全(五)
- 2013届高考数学单元考点复习12
- 雨霖铃精品课件




