第一范文网 - 专业文章范例文档资料分享平台

2015计算机学院毕业设计(优秀)--绿化管理系统 - 基于web服务 - 图文 (8)

来源:用户分享 时间:2020-06-18 本文由独酌伊人泪 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

}

catch (Exception) {

this.sql_release(); return false; }

this.sql_release();

return true;

7) public bool updatetable4_area_delete(string area):如果学校的原有的某一

块绿化区域现在要做别的用途,那么此时需要在系统中清除该绿化区域的所有信息及该区域,这时,应用程序端只要调用此函数便可删除该绿化区域及该区域上的所有绿化信息。该函数算法关键在于在删除区域之前需要先删除主表中所有有关该区域的绿化信息,否则数据库将出现异常,核心算法如下:

SqlCommand cmd;

cmd = new SqlCommand(@\FROM Table1 WHERE area='\+ area + @\mycon);//删除主表中所有有关该区域的绿化信息 try {

cmd.ExecuteNonQuery(); }

catch (Exception) { }

cmd = new SqlCommand(@\FROM Table4 WHERE area='\+ area + @\mycon);//删除该绿化区域 try {

cmd.ExecuteNonQuery(); }

catch (Exception) {

this.sql_release(); return false; }

this.sql_release();

return true;

8) public bool updatebackup_tree_deleted_Table(string id, string area,

string year, string month, string day, string standard_scale, string unit_scale, string value, string guanfu, string price, string kind, string remark):当主表中有绿化信息被删除时,需要提示是否备份该绿化信息,此函数就是用于备份被删除的绿化信息的,各参数分别代表备份表格中各个属性字段的值,备份表格中的主键值由系统自动生成。此函数主要算法在于要先判断该表格

中数据的函数,然后自动生成主键值,然后再将各字段插入数据表格中,核心算法如下:

SqlCommand cmd = new SqlCommand(@\backup_tree_deleted_Table\查询表格中数据

SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable mytable = new DataTable(); adapter.Fill(mytable);

int tmp = mytable.Rows.Count + 1;//根据表格中数据的行数加1作为主键值 cmd = new SqlCommand(@\

backup_tree_deleted_Table(number,id,area,[year of planting],[month of planting],[day of planting],[date of death],[standard of scale],[unit of scale],value,[guan fu],[price of buy],kind,remark) VALUES ('\

tmp.ToString().Trim() + @\@\+ day + @\+ System.DateTime.Now.ToString().Trim() + @\+ standard_scale + @\@\插入移除的绿化信息的各个属性值 try {

cmd.ExecuteNonQuery(); this.sql_release(); return true; }

catch (Exception) {

this.sql_release(); return false;

}

4.1.4数据库备份

对于管理系统来说备份和恢复功能必不可少,因为数据库随时都有崩溃的可能,对于此模块,web服务设计了两个函数public bool backup_sql(bool istmp)和public bool sql_resume(bool istmp)对数据库进行备份和还原,其中参数istmp为是否备份在临时文件夹里或从临时文件夹里恢复备份文件的信号。

为了保险,在应用程序端每次连到服务器要操作数据库的时候都先调用备份函数把现在的数据库保存到一个临时文件夹里,一旦数据库崩溃而老师又在操作前忘记了备份,则此时可从临时文件里恢复出现异常前的数据库状态。

此模块的核心思想是文件操作,代码如下: 数据库备份:

public bool backup_sql(bool istmp) {

this.sql_release(); try {

FileInfo sqlfile = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @\ FileInfo sqlfile_ldf = new

FileInfo(AppDomain.CurrentDomain.BaseDirectory + @\zhbit_log.ldf\

if (istmp) {

sqlfile.CopyTo(AppDomain.CurrentDomain.BaseDirectory + @\

sqlfile_ldf.CopyTo(AppDomain.CurrentDomain.BaseDirectory + @\ } else {

sqlfile.CopyTo(AppDomain.CurrentDomain.BaseDirectory + @\

sqlfile_ldf.CopyTo(AppDomain.CurrentDomain.BaseDirectory + @\ } }

catch (Exception) {

return false; }

return true;

}

数据库恢复:

public bool sql_resume(bool istmp) {

this.sql_release(); try {

FileInfo sqlfile; FileInfo sqlfile_ldf; if (istmp) {

sqlfile = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @\

sqlfile_ldf = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @\

} else {

sqlfile = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @\

sqlfile_ldf = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @\ }

sqlfile.CopyTo(AppDomain.CurrentDomain.BaseDirectory + @\

sqlfile_ldf.CopyTo(AppDomain.CurrentDomain.BaseDirectory + @\ }

catch (Exception) {

return false; }

return true;

}

4.2简单测试应用程序的开发

Web服务只是可供其他程序引用的一个网络类,开发的过程中需要再开发一个简单的应用程序来引用这个网络类,以便测试这个类中每一个函数的功能。

这个测试程序的开发依然采用Visual Studio 2008,下面将详细的讲解这个测试程序的开发过程。

首先,打开Visual Studio 2008,新建一个visual c#的窗体应用程序并将项目命名为webtest,如下图:

图4-1新建窗体程序

接下来测试主窗体设计如下:

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新工程科技2015计算机学院毕业设计(优秀)--绿化管理系统 - 基于web服务 - 图文 (8)全文阅读和word下载服务。

2015计算机学院毕业设计(优秀)--绿化管理系统 - 基于web服务 - 图文 (8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1085386.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top