无法直接粘贴图片
报告,源程序,介绍视频下载链接如下:
https://download.csdn.net/download/qq_54263076/87354460
每一张表所对应的角色的领域范围和空间如下:
第一子集.核酸总流程表:单号ID,待检员ID,取样员ID,取样时间,取样地点,核酸试剂编号ID
第二子集.人员表:人员ID,姓名,性别,身份证号,住址,手机号,工作单位,是否志愿者,身份ID
第三子集.志愿者表:人员ID,工作任务,志愿时长
第四子集.登录账号表:人员ID,账号(手机号),密码
第五子集.核酸试剂表:核酸试剂编号ID,检测员ID,检测时间,检测地点,检测结果ID
背景:近期,国内新冠肺炎疫情中高风险区持续增加,疫情防控工作面临新的压力与挑战。为切实做好我校疫情防控工作,根据国家、省、市新冠疫情防控最新工作要求,高校疫情期间,做到学生每日核酸,并要求手动打卡。
目的:此系统可以方便于校园疫情核酸管理,减少了手动打卡健康吗收集的繁琐流程,并快速获取学生核酸情况,做出安排。
主要为使用者,志愿者和统筹者三个主要用户。
(1)使用者是填写自己的基本信息和获取当前的核酸检测结果,并可申请成为志愿者;
(2)志愿者分为取样员,检测员,消毒人员等,取样员负责获取使用者信息与核酸试剂编号一一对应,填写核酸总流程表,检测员主要负责填写核酸试剂表,并上传检测结果;
(3)统筹者获取总体表的情况,快速获取每个人的核酸检测情况或志愿者工作情况,按照特点的条件筛选出特殊的人员,并进行统一安排。也可对志愿者进行工作任务分配和指挥,也可通过可视化地图进行Engine二次开发管理地图,进行核酸检测点的增删和路径分析;
本系统适用于吉林大学高校每日核酸检测管理,对于社会层面复杂情况,不予讨论。
| 名称 | 使用者完善个人信息 |
| 概述或简要描述 | 注册并登录系统,完善个人信息 |
| 参与者 | 使用者 |
| 触发器 | 登陆后必须填写完善个人信息 |
| 前置条件 | 用户成功登录 |
| 后置条件 | 成功保证用户数据库修改成功 |
| 事件路径 |
|
| 可选事件 | 申请志愿者 |
| 可选事件扩展点 |
|
表1.1 使用者用例举例
| 名称 | 志愿者上传信息 |
| 概述或简要描述 | 上传核酸总流程表信息,待测者和试剂编号必填 |
| 参与者 | 志愿者,使用者 |
| 触发器 | 采样志愿者每次需要做核酸时的信息绑定 检验志愿者,获取检验结果并修改核酸结果信息 |
| 前置条件 | 志愿者账号成功登录 |
| 后置条件 | 成功保证核酸总流程表中特定的信息修改成功 |
| 事件路径 |
|
| 可选事件 | 查看志愿工作地点和时间 |
| 可选事件扩展点 |
|
表1.2 志愿者用例举例
| 名称 | 统筹者获取并处理信息 |
| 概述或简要描述 | 按照特定条件查询并导出Excel表 |
| 参与者 | 统筹者 |
| 触发器 | 统筹者需要查询信息 |
| 前置条件 | 统筹者账号成功登录 |
| 后置条件 | 成功保证表的完成得出 |
| 事件路径 |
|
| 可选事件 | 处理志愿者信息 |
| 可选事件扩展点 |
|
表1.3 统筹者用例举例
下面都需要对应账号登录:
【1】使用者系统:
【2】志愿者系统:
【3】统筹者系统:
(3)人员核酸检测的总次数和最近时间(可导出Excel表),得到未作核酸人员的名单,并通过电话督促。
(4)获取志愿者名单(可导出Excel表),增加修改志愿任务,可以快速安排志愿者工作身份,让他们具有志愿者系统登录权限。
(5)选择和显示地图。
(6)对地图进行放大,缩小,定位,获取坐标点等基本操作。
(7)在地图上标注核酸检测点,并赋予详细属性,在再上传到任务数据库。
(8)在地图上进行图层的增删改查,并能获取图层的属性表。
(9)在地图上对图层中的要素进行增删改查,并能获取要素的属性值。
(10)能够进行简单的网络路径分析,进行障碍物与可通行点的增添。
C/S体系结构
C/S(Client/Server)结构,即客户机和服务器结构。这种体系结构模式是以数据库服务器为中心、以客户机为网络基础、在信息系统软件支持下的两层结构模型。这种体系结构中,用户操作模块布置在客户机上,数据存储在服务器上的数据库中。客户机依靠服务器获得所需要的网络资源,而服务器为客户机提供网络必须的资源。目前大多数信息系统是采用Client/Server结构。
1、测试时硬件:
| 处理器 | Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz |
| 基带RAM | 8.00GB |
| 系统类型 | 64 位操作系统, 基于 x64 的处理器 |
表1.4 电脑硬件
2、测试时网络:
| 网络类型 | 校园网JLU.PC |
| 链接速度 | 173 (Mbps) |
| 网络频带 | 5 GHz |
表1.5 电脑网络
该系统是1.0初始版本,里面大多数功能并不完善,如果需要进行二次更新扩展,可以进行以下项目:
(4)可扩展志愿者管理模块功能,对于志愿者的管理更详细
(5)可购买服务器并部署数据库
长春市卫生健康委员会提醒广大公众,零新增不等于零风险,要继续绷紧疫情防控这根弦,切实增强防护意识、遵守防控要求、配合防疫管理,做自己健康的第一责任人。 要密切关注各地发布的疫情动态信息,如与阳性感染者活动轨迹有交集,或近期有疫情发生地区旅居史,请立即主动向社区(村屯)或疾控机构报告,按要求配合做好相关疫情管控措施。如出现发热、咳嗽等急性呼吸道症状,请在做好个人防护的情况下,及时到定点医疗机构发热门]诊就诊。接种新冠疫苗是预防新冠肺炎的有效措施,请广大群众主动尽早接种,要坚持外出戴口罩、勤洗手、常通风、保持社交距离、不聚餐。
对于吉林大学高校要及时做好对核酸检测的统计与监管。
手动打卡,比较麻烦和繁琐,需要人工手动或验证查看,且容易漏检和蒙混,不好做到统计和及时做出调整反应。并且可以快速网络上安排志愿者进行核酸检测的志愿工作,做到与校外人员零接触,加强疫情防控的安全性。
无,全由个人完成
| 时间 | 任务 |
| 11.1-11.7 | 报告第一二章需求分析完成 |
| 11.8-11.10 | 完成所有表格的创建和基础数据的填充 |
| 11.11-11.12 | 完成账号管理登录功能 |
| 11.13-11.14 | 完成使用者系统基础功能 |
| 11.15-11.16 | 完成志愿者系统基础功能 |
| 11.17-11.24 | 完成统筹者系统基础功能 |
| 11.25-12.12 | Engine可视化地图开发 |
| 12.12-12.13 | 基础数据库的导入和导出 |
| 12.13-12.23 | 报告完成 |
| 12.23-12.29 | 介绍视频完成 |
表1.6 项目规划
数据库模型部分详细细节请看文件”ER模型报告.RTF”。
表2.1 Entity Summary Report
| Entity Name | Entity Type | Primary Keys | # Attr |
| 采样人员 | Independent | 采样人员ID | 4 |
| 待检人员 | Independent | 待检人员ID | 3 |
| 核酸流程 | Independent | 核酸流程ID | 6 |
| 检测结果 | Independent | 检测结果ID | 2 |
| 检测人员 | Independent | 检测人员ID | 4 |
| 人员 | Independent | 人员ID | 6 |
| 试剂 | Independent | 试剂ID | 6 |
| 账号 | Dependent | 人员ID | 3 |
| 账号权限 | Independent | 账号权限ID | 3 |
| 志愿任务 | Independent | 志愿任务ID | 7 |
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 人员ID | pID | integer | Primary Key |
| 姓名 | pName | Varchar(10) | |
| 性别 | pSex | Varchar(10) | |
| 电话号 | pPhone | Varchar(15) | Not null |
| 身份证号 | pIDnumber | Varchar(20) | Not null |
| 住址 | pAdd | Varchar(50) |
表2.1 People表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 人员ID | pID | integer | Primary Key |
| 账号密码 | aPassword | Varchar(20) | |
| 账号权限ID | auID | integer |
表2.2 AccNumber表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 账号权限ID | auID | integer | Primary Key |
| 权限名称 | auName | Varchar(10) | |
| 权限备注 | auRemark | Varchar(255) |
表2.3 AccAuthority表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 待检人员ID | wpID | integer | Primary Key |
| 人员ID | pID | integer | |
| 学号/工号 | stuNumber | Varchar(15) |
表2.4 WaitPeolple表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 采样人员ID | sampID | integer | Primary Key |
| 人员ID | pID | integer | |
| 志愿任务ID | voluID | integer | |
| 志愿时长 | volunTime | Float |
表2.5 SamplePeople表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 点图层ID | objectID | integer | |
| 志愿任务ID | voluID | integer | Primary Key |
| 工作任务名称 | volName | Varchar(20) | |
| 工作任务描述 | remark | Varchar(255) | |
| 开始工作时间 | starTime | Datetime | |
| 结束工作时间 | endTime | Datetime | |
| 工作地点 | volAdd | Varchar(20) |
表2.6 VolunTask表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 检测人员ID | detpID | integer | Primary Key |
| 人员ID | pID | integer | |
| 工作部门 | department | Varchar(20) | |
| 职务 | position | Varchar(20) |
表2.7 DetectPeople表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 核酸流程ID | listID | integer | Primary Key |
| 待检人员ID | wpID | integer | Not null |
| 采样人员ID | sampID | integer | Not null |
| 采样时间 | samTime | Datetime | |
| 采样地点 | samAdd | Varchar(20) | |
| 试剂ID | reaID | integer | Not null |
表2.8 DetectList表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 试剂ID | reaID | integer | Primary Key |
| 检测人员ID | detpID | integer | Not null |
| 检测时间 | deteTime | Datetime | |
| 检测结果ID | deterID | integer | Primary Key |
表2.9 Reagent表
| 中文名 | 英文名 | 数据类型 | 数据形式 |
| 检测结果ID | deterID | integer | Primary Key |
| 检测结果 | result | Varchar(10) |
表2.10 DetectResulty表
Relationship Summary Report
| Parent Entity | Child Entity | Relationship Type | No of Keys |
| 待检人员 | 核酸流程 | Non-Identifying | 1 |
| 采样人员 | 核酸流程 | Non-Identifying | 1 |
| 试剂 | 核酸流程 | Non-Identifying | 1 |
| 检测人员 | 试剂 | Non-Identifying | 1 |
| 账号权限 | 账号 | Non-Identifying | 1 |
| 账号 | 待检人员 | Non-Identifying | 1 |
| 账号 | 采样人员 | Non-Identifying | 1 |
| 账号 | 检测人员 | Non-Identifying | 1 |
| 人员 | 账号 | Identifying | 1 |
| 志愿任务 | 采样人员 | Non-Identifying | 1 |
| 检测结果 | 试剂 | Non-Identifying | 1 |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 待检人员 |
| Child Entity | 核酸流程 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 待检人员ID | 待检人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 采样人员 |
| Child Entity | 核酸流程 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 采样人员ID | 采样人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 试剂 |
| Child Entity | 核酸流程 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 试剂ID | 试剂ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 检测人员 |
| Child Entity | 试剂 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 检测人员ID | 检测人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 账号权限 |
| Child Entity | 账号 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 账号权限ID | 账号权限ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 账号 |
| Child Entity | 待检人员 |
| Cardinality | One to Exactly: 1 |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 人员ID | 人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 账号 |
| Child Entity | 采样人员 |
| Cardinality | One to Exactly: 1 |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 人员ID | 人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 账号 |
| Child Entity | 检测人员 |
| Cardinality | One to Exactly: 1 |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 人员ID | 人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 人员 |
| Child Entity | 账号 |
| Cardinality | One to Exactly: 1 |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 人员ID | 人员ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 志愿任务 |
| Child Entity | 采样人员 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 志愿任务ID | 志愿任务ID |
| Relationship Name | |
| Relationship Business Name | |
| Relationship Type | Non-Identifying |
| Relationship Do Not Generate | False |
| Relationship Logical Only | NO |
| Parent Entity | 检测结果 |
| Child Entity | 试剂 |
| Cardinality | One To Zero or More |
| Existence | Mandatory |
| Propagated Key | Primary Key |
Bound Attachments
| Name | Current Value |
Relationship Description
| Verb Sentence | |
| Inverse Verb Sentence | |
| Definition | |
| Note |
Relationship Keys
| Parent Key | Child Key |
| 检测结果ID | 检测结果ID |
逻辑模型,是指数据的逻辑结构。逻辑建模是数据仓库实施中的重要一环,因为它能直接反映出业务部门的需求,同时对系统的物理实施有着重要的指导作用,它的作用在于可以通过实体和关系勾勒出企业的数据蓝图。
逻辑模型是严格定义的一组概念的集合,主要由数据结构、数据操作和完整性约束部分组成,通常称为数据三要素。
数据结构是计算机数据组织方式和数据之间联系的框架描述,而数据文件的数据就按照这种框架描述进行组织。
数据结构是所描述对象类型的集合,是对系统的静态描述。
数据操作是指对数据库中各种对象的实例或取值所允许执行操作的集合,其中包括操作方法及有关规则,它是对数据库动态特性的描述。
完全性约束是指对数据的一组完整性规则(约束条件)的集合。逻辑逻辑应该反映和和规定本数据模型必须遵守的基本的通用的完整性约束条件。例如,在关系模型中,任何关系都必须满足实体完整性和参照完整性两个条件。此外,逻辑模型还应该提供用户定义完整性约束条件的机制,以反映具体应用所涉及的数据必须遵守的特定的语义约束条件。
细节查看第二章内容。
建立关系和E-R图,将关系转化为表:1:1关系,1:n关系,m:n关系。对象关联的数据库表示:
图3.1 数据库逻辑E-R图
物理数据模型(Physical Data Model,PDM),是指提供系统初始设计所需要的基础元素,以及相关元素之间的关系。即用于存储结构和访问机制的更高层描述,描述数据是如何在计算机中存储的,如何表达记录结构、记录顺序和访问路径等信息。使用物理数据模型,可以在系统层实现数据库。数据库的物理设计阶段必须在此基础上进行详细的后台设计,包括数据库的存储过程、操作、触发、视图和索引表等;本报告通过Microsoft SQL Server Management Studio 18软件构建数据库的物理模型。
图3.2 数据库物理E-R图
此物理模型的生成详情查看文件”数据库生成.sql”。
本次课程我开发所用到的软件如下:
1.Microsoft SQL Server Management Studio 18
2.Visual Studio 2012
3.ArcMap 10.2
4.ArcEngine 10.2
1.新建数据库nucleic
图4.1 新建数据库
图4.2 输入数据库名称
2.导入初始数据
双击”数据库生成.sql”,在SQL SERVER中点击“执行”。
图4.3 打开”数据库生成.sql”
图4.4 点击执行
初始数据数据初始化完成
主要用来方便用于代码的复用
class SQL
{
public static SqlConnection sqlcon = new SqlConnection();//定义链接变量
public SQL()
{
sqlcon.ConnectionString = "Data Source=" + STATIC.local + ";Initial Catalog=nucleic;Integrated Security=True";//连接服务器
}
//sql操作返回处理的行数
public int excute(String sql)
{
int i = 0;
sqlcon.Open();
if (sqlcon.State == ConnectionState.Open)
{
try
{
//数据库命令
SqlCommand cmd = new SqlCommand(sql, sqlcon);
//返回操作行数
i = cmd.ExecuteNonQuery();
}
catch (Exception es) { MessageBox.Show(es.Message); }
}
sqlcon.Close();
return i;
}
//sql查询
public selectDate select(String sql)
{
//建立数据集 实例化Datatable类
selectDate sd = new selectDate();
DataSet d1 = new DataSet();
sqlcon.Open();
try
{
if (sqlcon.State == ConnectionState.Open)
{
//建立数据库适配器 建立SQL语句与数据库的连接
SqlDataAdapter ada = new SqlDataAdapter(sql, sqlcon);
//将结果装入ds01中
ada.Fill(d1);
sd.ds = d1;
sqlcon.Close();
sqlcon.Open();
SqlCommand cmd1 = new SqlCommand(sql, sqlcon);
SqlDataReader data = cmd1.ExecuteReader();
//是否有数据
bool hasrows = data.HasRows;
sd.hasrows = hasrows;
}
}
catch (Exception es) { MessageBox.Show(es.Message); }
sqlcon.Close();
return sd;
}
}
//查询语句返回的数据类型,包括 查询数据集合,是否有数据
class selectDate
{
public DataSet ds = new DataSet() ;//查询数据集
public bool hasrows;//是否查询到数据
}
//全局变量类
class STATIC
{
public static int ID=1;//pID号
public static int wpID=0;//wpID
public static int sampID = 0;//sampID
public static int detpID = 0;//detpIDID
public static string local=" ";//实例名
}
图5.1 登录
private void button1_Click(object sender, EventArgs e)
{
String system = comboBox1.Text;
String phone = textBox1.Text;
String password = textBox2.Text;
//SQL语句,可自己编写需要的。
string sql = "select auID from AccNumber where pID=(select pID from dbo.People where pPhone='" + phone+"') and aPassword='"+password+"'";
selectDate sd = SQL1.select(sql);
try
{
auID = (int)sd.ds.Tables[0].Rows[0]["auID"];
}
catch{
MessageBox.Show("账号或密码错误,没有账号请先注册账号");
return;
};
string sql3 = "select pID from dbo.People where pPhone='" + phone + "'";
selectDate sd3 = SQL1.select(sql3);
int ID = Int32.Parse(sd3.ds.Tables[0].Rows[0]["pID"].ToString());
STATIC.ID = ID;
//权限登录
if (comboBox1.Text == "普通人员"&auID!=6)
{
MessageBox.Show("欢迎来到普通人员系统!");
Form f1=new 系统窗口.普通人员系统();
f1.Show();
}
else if (comboBox1.Text == "采样者系统" & (auID == 2 || auID == 5))
{
MessageBox.Show("欢迎来到志愿者系统!");
Form f1 = new 系统窗口.志愿者系统();
f1.Show();
}
else if (comboBox1.Text == "检测者系统" & (auID == 3 || auID == 5))
{
MessageBox.Show("欢迎来到检测者系统!");
Form f1 = new 系统窗口.检测者系统();
f1.Show();
}
else if (comboBox1.Text == "管理者系统" & (auID == 4 || auID == 5))
{
MessageBox.Show("欢迎来到管理者系统!");
Form f1 = new 系统窗口.管理员系统();
f1.Show();
}
else { MessageBox.Show("权限不足,请联系管理员"); }
}
图5.2 注册
private void button4_Click_1(object sender, EventArgs e)
{
string name = textBox3.Text;
string sex = comboBox2.Text;
string phone = textBox4.Text;
string number = textBox5.Text;
string add = textBox6.Text;
string password = textBox7.Text;
string repassword = textBox8.Text;
if (password != repassword)
{
MessageBox.Show("俩次密码不一致");
return;
}
if (textBox3.Text == string.Empty & textBox4.Text == string.Empty & textBox5.Text == string.Empty & textBox6.Text == string.Empty)
{
MessageBox.Show("不能为空");
return;
}
try
{ //格式要求全是数字
float iphone = float.Parse(phone);
float inumber = float.Parse(number);
//SQL语句,可自己编写需要的。
string sql1 = "select * from dbo.People where pIDnumber='" + number + "' or pPhone = '" + phone + "'";
selectDate sd = SQL1.select(sql1);
if (sd.hasrows == true)
{//如果查找到
MessageBox.Show("已存在该用户手机号或身份证");
return;
}
else
{
//SQL语句,可自己编写需要的。
string sql2 = "insert into dbo.People(pName,pSex,pPhone,pIDnumber,pAdd) values('" + name + "','" + sex + "','" + phone + "','" + number + "','" + add + "')";
int i = SQL1.excute(sql2);
if (i >= 1)
{
MessageBox.Show("注册成功");
tabControl1.SelectedIndex = 0;
//获取ID
//SQL语句,可自己编写需要的。
string sql3 = "select pID from dbo.People where pPhone='" + phone + "'";
//建立数据库适配器 建立SQL语句与数据库的连接
selectDate sd3 = SQL1.select(sql3);
int ID = Int32.Parse(sd3.ds.Tables[0].Rows[0]["pID"].ToString());
//插入密码表
//SQL语句,可自己编写需要的。
string sql4 = "insert into dbo.AccNumber(pID,aPassword,auID) values(" + ID + ",'" + password + "','1')";
//建立数据库适配器 建立SQL语句与数据库的连接
int i4 = SQL1.excute(sql4);
}
else { MessageBox.Show("注册失败"); }
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
图5.3 首页
public 普通人员系统()
{
InitializeComponent();
//检测是否存在登录账号,如果存在则在待检人员表里加入
//SQL语句,可自己编写需要的。
string sql = "select * from dbo.WaitPeople where pID="+STATIC.ID;
selectDate sd = SQL1.select(sql);
if (!sd.hasrows)//如果不存在待测人员账号
{
string sql1 = "insert dbo.WaitPeople(pID) values(" + STATIC.ID + ")";
int i = SQL1.excute(sql1);
if (i >= 1)
{
MessageBox.Show("成功创建待测人员账号");
}
}
//查询个人信息;
peopleInformation();
//获取本待测人员ID,为了数据的安全性,用wpID代替
selectDate sd2 = SQL1.select(sql);
STATIC.wpID = Int32.Parse(sd2.ds.Tables[0].Rows[0]["wpID"].ToString());
//获取本人检测信息
detectResult();
}
图5.4 个人信息
//个人信息
public void peopleInformation()
{
string sql = "select * from dbo.People where pID=" + STATIC.ID;
selectDate sd = SQL1.select(sql);
DataRow dr=sd.ds.Tables[0].Rows[0];
textBox1.Text = dr["pName"].ToString();
textBox2.Text = dr["pSex"].ToString();
textBox3.Text = dr["pPhone"].ToString();
textBox4.Text = dr["pIDnumber"].ToString();
textBox5.Text = dr["pAdd"].ToString();
string sql2 = "select * from dbo.WaitPeople where pID=" + STATIC.ID;
selectDate sd2 = SQL1.select(sql2);
DataRow dr2 = sd2.ds.Tables[0].Rows[0];
textBox6.Text = dr2["stuNumber"].ToString();
string sql3 = "select * from dbo.SamplePeople where pID=" + STATIC.ID;
selectDate sd3 = SQL1.select(sql2);
textBox7.Text = sd3.hasrows ? "是" : "否";
}
public int buttonclick = 0;
private void button1_Click(object sender, EventArgs e)
{
if (buttonclick == 0)
{
button1.Text = "取消";
textBox1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;
textBox5.Enabled = true;
textBox6.Enabled = true;
buttonclick =1;
}
else {
button1.Text = "修改";
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
textBox5.Enabled = false;
textBox6.Enabled = false;
buttonclick =0;
peopleInformation();
}
}
private void button2_Click(object sender, EventArgs e)
{
string name = textBox1.Text;
string sex = textBox2.Text;
string phone = textBox3.Text;
string number = textBox4.Text;
string add = textBox5.Text;
if (textBox1.Text == string.Empty & textBox2.Text == string.Empty & textBox3.Text == string.Empty & textBox4.Text == string.Empty & textBox5.Text == string.Empty)
{
MessageBox.Show("不能为空");
return;
}
try
{ //格式要求全是数字
float iphone = float.Parse(phone);
float inumber = float.Parse(number);
//SQL语句,可自己编写需要的。
string sql1 = "select * from dbo.People where pIDnumber='" + number + "' or pPhone = '" + phone + "'";
selectDate sd = SQL1.select(sql1);
DataRow dr = sd.ds.Tables[0].Rows[0];
if (sd.hasrows == true&&(dr["pPhone"].ToString()!=phone|| dr["pIDnumber"].ToString() != number))
{//如果查找到
MessageBox.Show("已存在该用户手机号或身份证");
return;
}
else
{
//SQL语句,可自己编写需要的。
string sql2 = "update dbo.People set pName='" + name + "',pSex='" + sex + "',pPhone='" + phone + "',pIDnumber='" + number + "',pAdd='" + add + "' where pID="+STATIC.ID ;
int i = SQL1.excute(sql2);
if (i >= 1)
{
MessageBox.Show("保存成功");
button1.Text = "修改";
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
textBox5.Enabled = false;
textBox6.Enabled = false;
buttonclick = 0;
}
else { MessageBox.Show("保存失败"); }
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
图5.5 记录和排名
//检测结果
public void detectResult()
{
//更新检测表
string sql = "select p.pName as '待检人员',w.stuNumber as '学号', sp.pName as '采样人员',l.samTime as '采样时间',l.samADD as '采样地点',dp.department as '检测机构',ddp.pName as '检测人员',t.result as '检测结果',r.deteTime as '检测时间',r.reRemark as '备注' from WaitPeople w ,SamplePeople s,Reagent r,DetectResult t ,DetectList l ,DetectPeople dp,People p,People sp,People ddp where((l.wpID=w.wpID) and(l.sampID=s.sampID) and(l.reaID=r.reaID) and(r.deterID=t.deterID) and(r.detpID=dp.detpID) and(p.pID=w.pID) and(sp.pID=s.pID) and(ddp.pID=dp.pID) and ( w.wpID=" + STATIC.wpID + ") ) order by l.samTime desc";
selectDate sd = SQL1.select(sql);
detectTable = sd.ds.Tables[0];
if (sd.hasrows == true)
{
label1.Text = detectTable.Rows[0]["检测结果"].ToString();
label3.Text = detectTable.Rows[0]["检测时间"].ToString();
}
else
{
label1.Text = "未检测";
label3.Text = "未检测";
}
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = detectTable;
//更新排名
string sql2 = "select rank,count from (select rank() over(order by COUNT(wpID) desc) as rank,wpID,COUNT(wpID) as count from DetectList group by wpID) r where wpID=" + STATIC.wpID;
selectDate sd2 = SQL1.select(sql2);
if (sd2.hasrows == true)
{
int rank = int.Parse(sd2.ds.Tables[0].Rows[0]["rank"].ToString());
int count = int.Parse(sd2.ds.Tables[0].Rows[0]["count"].ToString());
string sql3 = "select count(*) as totle from (select rank() over(order by COUNT(wpID) desc) as rank,wpID,COUNT(wpID) as count from DetectList group by wpID) r";
selectDate sd3 = SQL1.select(sql3);
int totle = int.Parse(sd3.ds.Tables[0].Rows[0]["totle"].ToString());
label6.Text = "你已经做了" + count.ToString() + "次核酸";
label9.Text = "超过了" + ((int)((1 - (rank - 1) / totle) * 1000) / 10).ToString() + "%的检测人员,继续努力哦!";
}
else {
label6.Text = "你还未做核酸";
label9.Text = "未超过任何人";
}
}
图5.6 首页
//初始化
public void Initial()
{
string sql0 = "select * from dbo.SamplePeople where pID=" + STATIC.ID;
selectDate sd0=SQL1.select(sql0);
comboBox1.SelectedIndex = 0;
//如果没有需要创建采样者账号
if (sd0.hasrows == false)
{
string sql2 = "insert into SamplePeople(pID) values("+STATIC.ID+")";
MessageBox.Show("志愿者账号创建成功!");
SQL1.excute(sql2);
sd0 = SQL1.select(sql0);
}
//更新志愿者ID
STATIC.sampID = Int32.Parse(sd0.ds.Tables[0].Rows[0]["sampID"].ToString());
//首页
string sql = "select * from dbo.People where pID=" + STATIC.ID;
selectDate sd = SQL1.select(sql);
string name= sd.ds.Tables[0].Rows[0]["pName"].ToString();
label5.Text = "欢迎 " + name + " 来到志愿者系统";
string sql3 = "select * from dbo.samplePeople where pID=" + STATIC.ID;
selectDate sd3 = SQL1.select(sql3);
string time = sd3.ds.Tables[0].Rows[0]["volunTime"].ToString();
label6.Text = "您的志愿时长为:" + time;
//显示任务表格
taskTable();
//显示核酸采样记录
sampleTable();
}
图5.7 上传
private void button1_Click_1(object sender, EventArgs e)
{ //上传
if (textBox3.Text == "无任务") { MessageBox.Show("你没有任务,快去申请任务");return; }
string phone = textBox1.Text;
string time = textBox2.Text;
string add = textBox3.Text;
string reName = textBox4.Text;
if (add == string.Empty)
{
MessageBox.Show("对不起,您还没有选择任务\n请在任务界面选择自己的任务");
return;
}
//首先检测有没有该试剂
string sql0 = "select * from dbo.Reagent where reName='" + reName + "'";
selectDate sd0 = SQL1.select(sql0);
if (sd0.hasrows == false)
{
//插入该试剂
string sql1 = "insert into dbo.Reagent(reName) values('" + reName + "')";
selectDate sd1 = SQL1.select(sql1);
MessageBox.Show("新建试剂"+reName+"成功");
sd0 = SQL1.select(sql0);
}
try
{
//找到该手机号的人员ID
string sql = "select * from dbo.People p ,dbo.WaitPeople wp where p.pID=wp.pID and pPhone='" + phone + "'";
selectDate sd = SQL1.select(sql);
int wid = Int32.Parse(sd.ds.Tables[0].Rows[0]["wpID"].ToString());
//找到该试剂ID
int reid = Int32.Parse(sd0.ds.Tables[0].Rows[0]["reaID"].ToString());
//插入核酸流程表
string sql2 = "insert into dbo.DetectList(wpID,sampID,samTime,samAdd,reaID) values(" + wid + "," + STATIC.sampID + ",'" + time + "','" + add + "'," + reid + ")";
SQL1.excute(sql2);
MessageBox.Show("上传成功");
sampleTable();
}
catch { MessageBox.Show("没有找到该人员或者该人员没有登录过一次系统"); }
}
图5.8 任务和申请
//显示任务表格
public void taskTable()
{
//所有任务
string sql = "select voluID,volName as 任务名称 ,starTime as 开始时间,endTime as 结束时间,volAdd as 任务地址 ,remark as 备注 from dbo.VolunTask";
selectDate sd = SQL1.select(sql);
dataGridView2.ReadOnly = true;
dataGridView2.DataSource = sd.ds.Tables[0];
//个人任务
string sql2 = "select voluID,volName as 任务名称 ,starTime as 开始时间,endTime as 结束时间,volAdd as 任务地址 ,remark as 备注 from dbo.VolunTask where voluID=(select voluID from samplePeople where sampID="+STATIC.sampID+")";
selectDate sd2 = SQL1.select(sql2);
try
{
textBox3.Text = sd2.ds.Tables[0].Rows[0]["任务地址"].ToString();
}
catch {
textBox3.Text = "无任务";
}
dataGridView3.ReadOnly = true;
dataGridView3.DataSource = sd2.ds.Tables[0];
}
private void button2_Click_1(object sender, EventArgs e)
{
try
{
int id = Int32.Parse(textBox5.Text);
DialogResult dr = MessageBox.Show("修改后,当前任务会被刷新,确定修改?", "修改任务", MessageBoxButtons.OKCancel);
if (dr == DialogResult.OK)
{
string sql = "update dbo.SamplePeople set voluID=" + id;
SQL1.excute(sql);
//显示任务表格
taskTable();
}
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
}
}
//显示核酸采样记录
public void sampleTable()
{
string sql = "select l.listID as 'ID', p.pName as '待检人员',w.stuNumber as '学号', sp.pName as '采样人员',l.samTime as '采样时间',l.samADD as '采样地点',r.reName as '试剂名称' from WaitPeople w ,SamplePeople s,Reagent r,DetectList l ,People p,People sp where((l.wpID=w.wpID) and(l.sampID=s.sampID) and(l.reaID=r.reaID) and(s.sampID="+STATIC.sampID+") and(p.pID=w.pID) and(sp.pID=s.pID)) order by l.samTime desc";
selectDate sd = SQL1.select(sql);
samplelist = sd.ds.Tables[0];//列表赋值
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = sd.ds.Tables[0];
}
5.4.4.1排名
图5.9 排名
//显示排名情况
string sql2 = " select rank,count from (select rank() over(order by COUNT(sampID) desc) as rank,sampID,COUNT(sampID) as count from DetectList group by sampID) r where r.sampID=" + STATIC.sampID;
selectDate sd2 = SQL1.select(sql2);
if (sd2.hasrows == true)
{
int rank = int.Parse(sd2.ds.Tables[0].Rows[0]["rank"].ToString());
int count = int.Parse(sd2.ds.Tables[0].Rows[0]["count"].ToString());
string sql3 = "select count(*) as totle from (select rank() over(order by COUNT(sampID) desc) as rank,sampID,COUNT(wpID) as count from DetectList group by sampID) r";
selectDate sd3 = SQL1.select(sql3);
int totle = int.Parse(sd3.ds.Tables[0].Rows[0]["totle"].ToString());
label7.Text = "你已经采样了" + count.ToString() + "次核酸";
label8.Text = "超过了" + ((int)((1 - (rank - 1) / totle) * 1000) / 10).ToString() + "%的志愿者,继续努力哦!";
}
else {
label7.Text = "你还未做过任何采样活动";
label8.Text = "未超过任何人";
}
5.4.4.2采样记录查询
图5.10 查询
private void button4_Click(object sender, EventArgs e)
{
string text = comboBox1.Text;
string att="";
switch(text)
{
case "待检人员": att = "p.pName"; break;
case "采样地点": att = "l.samAdd"; break;
case "试剂名称": att = "r.reName"; break;
}
string sql = "select l.listID as 'ID', p.pName as '待检人员',w.stuNumber as '学号', sp.pName as '采样人员',l.samTime as '采样时间',l.samADD as '采样地点',r.reName as '试剂名称' from WaitPeople w ,SamplePeople s,Reagent r,DetectList l ,People p,People sp where((l.wpID=w.wpID) and(l.sampID=s.sampID) and(l.reaID=r.reaID) and(s.sampID=" + STATIC.sampID + ") and(p.pID=w.pID) and(sp.pID=s.pID) and ("+att+"='"+textBox6.Text+"')) order by l.samTime desc";
selectDate sd = SQL1.select(sql);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = sd.ds.Tables[0];
if(sd.hasrows==true)MessageBox.Show("查询成功!");
}
5.4.4.3修改
图5.11 修改
private void button6_Click(object sender, EventArgs e)
{
var rows = dataGridView1.SelectedRows ;
foreach (DataGridViewRow r in rows )
{
try
{ string ID = r.Cells["ID"].Value.ToString();
string time = r.Cells["采样时间"].Value.ToString();
string add = r.Cells["采样地点"].Value.ToString();
string sql1 = "update dbo.DetectList set samTime='"+time+"',samAdd='"+add+"' where listID="+ID;
SQL1.excute(sql1);
sampleTable();
MessageBox.Show("修改成功!");
}
catch (Exception ex) {MessageBox.Show( ex.Message); }
}
5.4.4.4 删除
图5.12 删除
private void button5_Click(object sender, EventArgs e)
{
var rows = dataGridView1.SelectedRows ;
foreach (DataGridViewRow r in rows )
{
try
{
string ID = r.Cells["ID"].Value.ToString();
string sql = "delete from dbo.DetectList where listID=" + ID;
SQL1.excute(sql);
sampleTable();
MessageBox.Show("删除成功!");
}
catch { }
}
}
图5.13 首页
与采样者系统代码类似,代码略。
图5.14 上传
与采样者系统代码类似,代码略。
图5.15 个人信息
与采样者系统代码类似,代码略。
图5.16 记录
与采样者系统代码类似,代码略。
5.6.1.1查看表格
图5.17 查看表格
private void button1_Click(object sender, EventArgs e)
{
string table = comboBox1.Text;
string sql = "";
switch (table)
{
case "所有人员": sql = "select pID as ID,pName as 姓名 ,pSex as 性别,pPhone as 电话号,pIDnumber as 身份证号 ,pAdd as 住址 from people"; break;
case "所有待测者": sql = "select p.pID as ID,pName as 姓名 ,w.stuNumber as 学号,pSex as 性别,pPhone as 电话号,pIDnumber as 身份证号 ,pAdd as 住址 from people p,WaitPeople w where p.pID=w.pID"; break;
case "所有检测者": sql = "select p.pID as ID,pName as 姓名 ,pSex as 性别,w.department as 机构,w.position as 职务,pPhone as 电话号,pIDnumber as 身份证号 ,pAdd as 住址 from people p,DetectPeople w where p.pID=w.pID"; break;
case "所有采样者": sql = "select p.pID as ID,pName as 姓名 ,pSex as 性别,pPhone as 电话号,pIDnumber as 身份证号 ,pAdd as 住址 from people p,SamplePeople w where p.pID=w.pID"; break;
case "所有管理者": sql = "select p.pID as ID,pName as 姓名 ,pSex as 性别,pPhone as 电话号,pIDnumber as 身份证号 ,pAdd as 住址 from people p,AccNumber n where (p.pID=n.pID)and (n.auID=4|5)"; break;
}
MessageBox.Show("查找成功!");
richTextBox1.Text = comboBox1.Text;
selectDate sd = SQL1.select(sql);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = sd.ds.Tables[0];
t = sd.ds.Tables[0];
coluName();
}
5.6.1.2权限管理
图5.18 权限管理
private void button3_Click(object sender, EventArgs e)
{
string ID = textBox2.Text;
string au = comboBox3.Text;
string sql = "update AccNumber set auID=(select auID from AccAuthority where auName='" + comboBox3.Text + "') where pID=" + ID;
int i = SQL1.excute(sql);
if (i > 0) { MessageBox.Show("设置成功!"); }
//查看所有人员权限
string sql2 = "select p.pID as ID ,pName as 姓名,pPhone as 手机号,auName as 权限 from People p,AccNumber a,AccAuthority au where p.pID=a.pID and a.auID=au.auID";
showTable(SQL1.select(sql2).ds.Tables[0], "权限表");
}
图5.19 任务管理
5.6.2.1新建
//新建任务
private void button4_Click(object sender, EventArgs e)
{
string name = textBox4.Text;
string star = textBox6.Text;
string end = textBox8.Text;
string add = textBox10.Text;
string remark = textBox12.Text;
string sql = "insert into dbo.VolunTask( volName, starTime,endTime,volAdd,remark) values('" + name + "','" + star + "','" + end + "','" + add + "','" + remark + "')";
int i = SQL1.excute(sql);
if (i > 0) { MessageBox.Show("新建任务成功!"); }
string sql2 = "select volName as 任务名称 ,starTime as 任务开始时间,endTime as 任务结束时间 ,volAdd as 任务地点 ,remark as 备注 from dbo.VolunTask";
showTable(SQL1.select(sql2).ds.Tables[0], "所有任务表");
}
5.6.2.2查询
//查看所有任务
private void button5_Click(object sender, EventArgs e)
{
string sql2 = "select voluID,volName as 任务名称 ,starTime as 任务开始时间,endTime as 任务结束时间 ,volAdd as 任务地点 ,remark as 备注 from dbo.VolunTask";
showTable(SQL1.select(sql2).ds.Tables[0], "所有任务表");
}
5.6.2.3删除
private void button6_Click(object sender, EventArgs e)
{
var rows = dataGridView1.SelectedRows;
foreach (DataGridViewRow r in rows)
{
try
{
string ID = r.Cells["voluID"].Value.ToString();
string sql = "delete from dbo.VolunTask where voluID=" + ID;
SQL1.excute(sql);
MessageBox.Show("删除成功!");
}
catch { }
}
string sql2 = "select voluID,volName as 任务名称 ,starTime as 任务开始时间,endTime as 任务结束时间 ,volAdd as 任务地点 ,remark as 备注 from dbo.VolunTask";
showTable(SQL1.select(sql2).ds.Tables[0], "所有任务表");
}
图5.20 核酸管理
5.6.3.1查看所有
private void button7_Click(object sender, EventArgs e)
{
string sql = "select p.pName as '待检人员',w.stuNumber as '学号', sp.pName as '采样人员',l.samTime as '采样时间',l.samADD as '采样地点',dp.department as '检测机构',ddp.pName as '检测人员',t.result as '检测结果',r.deteTime as '检测时间',r.reRemark as '备注' from WaitPeople w ,SamplePeople s,Reagent r,DetectResult t ,DetectList l ,DetectPeople dp,People p,People sp,People ddp where((l.wpID=w.wpID) and(l.sampID=s.sampID) and(l.reaID=r.reaID) and(r.deterID=t.deterID) and(r.detpID=dp.detpID) and(p.pID=w.pID) and(sp.pID=s.pID) and(ddp.pID=dp.pID) ) order by l.samTime desc";
showTable(SQL1.select(sql).ds.Tables[0], "核酸流程表");
}
5.6.3.2查看未做核酸
private void button9_Click(object sender, EventArgs e)
{
try
{
string day = textBox15.Text;
string sql = "select a.pName as 姓名,a.stuNumber as 学号,a.pSex as 性别,a.pPhone as 电话,a.stuNumber as 身份证号,a.pAdd as 地址,b.samTime as 最新采样时间 from (select p.pID,wpID,p.pName,p.pSex,w.stuNumber,p.pPhone,p.pAdd from People p,WaitPeople w where p.pID=w.pID) a left join (select d.wpID,MAX(d.samTime) as samTime from DetectList d group by d.wpID) b on a.wpID=b.wpID where samTime is NULL or GETDATE()- samTime>" + day;
selectDate sd = SQL1.select(sql);
showTable(sd.ds.Tables[0], "未做核酸" + day + "天的人员");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
图5.21 查询和导出
//筛选
private void button2_Click(object sender, EventArgs e)
{
try
{
String symbol = comboBox4.Text;
switch (symbol)
{
case "=": for (int i = 0; i < t.Rows.Count; i++)
{
if ((t.Rows[i][comboBox2.Text]).ToString() != textBox1.Text)
{
t.Rows.RemoveAt(i);
}
}; richTextBox1.Text += "_" + comboBox2.Text + "=" + textBox1.Text; break;
case ">": for (int i = 0; i < t.Rows.Count; i++)
{
if (t.Rows[i][comboBox2.Text].GetType() == typeof(int) || t.Rows[i][comboBox2.Text].GetType() == typeof(float) || t.Rows[i][comboBox2.Text].GetType() == typeof(double))
{
if (float.Parse((t.Rows[i][comboBox2.Text]).ToString()) <= float.Parse(textBox1.Text))
{
t.Rows.RemoveAt(i);
}
}
else if (t.Rows[i][comboBox2.Text].GetType() == typeof(DateTime))
{
if (Convert.ToDateTime(t.Rows[i][comboBox2.Text]) <= Convert.ToDateTime(textBox1.Text))
{
t.Rows.RemoveAt(i);
}
}
else
{
MessageBox.Show("字符串比较大小没有意义哦!"); return;
}
}; richTextBox1.Text += "_" + comboBox2.Text + ">" + textBox1.Text; break;
case "<": for (int i = 0; i < t.Rows.Count; i++)
{
if (t.Rows[i][comboBox2.Text].GetType() == typeof(int) || t.Rows[i][comboBox2.Text].GetType() == typeof(float) || t.Rows[i][comboBox2.Text].GetType() == typeof(double))
{
if (float.Parse((t.Rows[i][comboBox2.Text]).ToString()) >= float.Parse(textBox1.Text))
{
t.Rows.RemoveAt(i);
}
}
else if (t.Rows[i][comboBox2.Text].GetType() == typeof(DateTime))
{
if (Convert.ToDateTime(t.Rows[i][comboBox2.Text]) >= Convert.ToDateTime(textBox1.Text))
{
t.Rows.RemoveAt(i);
}
}
else
{
MessageBox.Show("字符串比较大小没有意义哦!"); return;
}
}; richTextBox1.Text += "_" + comboBox2.Text + "<" + textBox1.Text; break;
case "!=": for (int i = 0; i < t.Rows.Count; i++)
{
if ((t.Rows[i][comboBox2.Text]).ToString() == textBox1.Text)
{
t.Rows.RemoveAt(i);
}
}; richTextBox1.Text += "_" + comboBox2.Text + "!=" + textBox1.Text; break;
}
}
catch (Exception ex) { MessageBox.Show("错误:" + ex.Message + "\n小贴士提醒您:请正确输入!!!"); return; }
dataGridView1.DataSource = t;
MessageBox.Show("筛选成功!");
}
图5.22 打开地图
private void 朝阳校区ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.ClearLayers();
string url = Application.StartupPath + "./地图/朝阳校区.mxd";
axMapControl1.LoadMxFile(url);
richTextBox2.Text ="朝阳"+ "校区核酸检测";
}
private void 南湖校区ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.ClearLayers();
string url = Application.StartupPath + "./地图/南湖校区.mxd";
axMapControl1.LoadMxFile(url);
richTextBox2.Text = "南湖" + "校区核酸检测";
}
private void 新民校区ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.ClearLayers();
string url = Application.StartupPath + "./地图/新民校区.mxd";
axMapControl1.LoadMxFile(url);
richTextBox2.Text = "新民" + "校区核酸检测";
}
private void 南岭校区ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.ClearLayers();
string url = Application.StartupPath + "./地图/南岭校区.mxd";
axMapControl1.LoadMxFile(url);
richTextBox2.Text = "南岭" + "校区核酸检测";
}
private void 前卫南区ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.ClearLayers();
string url = Application.StartupPath + "./地图/中心校区.mxd";
axMapControl1.LoadMxFile(url);
richTextBox2.Text = "中心" + "校区核酸检测";
}
图5.23 工具
5.6.6.1鼠标点击事件
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{
try
{
if (e.button == 2)
{
function = string.Empty;
}
string mapUnit = string.Empty;
switch (axMapControl1.MapUnits)
{
case esriUnits.esriKilometers: mapUnit = "千米"; break;
case esriUnits.esriMeters: mapUnit = "米"; break;
case esriUnits.esriInches: mapUnit = "英尺"; break;
case esriUnits.esriMiles: mapUnit = "英里"; break;
case esriUnits.esriCentimeters: mapUnit = "厘米"; break;
case esriUnits.esriDecimalDegrees: mapUnit = "十进制"; break;
default: mapUnit = "未知单位"; break;
}
IEnvelope envelop;
IGeometry geometry;
switch (function)
{
case "coordinate":
MessageBox.Show("当前地点的坐标为:x:" + e.mapX + mapUnit + ",y:" + e.mapY + mapUnit);
break;
case "ZoomIn":
envelop = axMapControl1.TrackRectangle();
axMapControl1.Extent = envelop;
axMapControl1.Refresh();
break;
case "select":
geometry = axMapControl1.TrackRectangle();
axMapControl1.Map.SelectByShape(geometry, null, false);
MessageBox.Show("已选择要素" + axMapControl1.Map.SelectionCount + "个");
axMapControl1.Refresh();
break;
case "createPoint":
IFeatureLayer pFLayer = axMapControl1.get_Layer(findlayerByname("核酸检测点")) as IFeatureLayer;
IFeatureClass pFC = pFLayer.FeatureClass;
//类型不对停止编辑\n
if (pFC.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { return; }
//建立编辑空间\n
IDataset pDataset = pFC as IDataset;
IWorkspace pWorkspace = pDataset.Workspace;
IWorkspaceEdit pWorkspaceEdit = pWorkspace as IWorkspaceEdit;
//开始编辑\n
pWorkspaceEdit.StartEditing(false);
pWorkspaceEdit.StartEditOperation();
//创建点\n
ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
point.X = e.mapX;
point.Y = e.mapY;
richTextBox4.Text = point.X.ToString();
richTextBox5.Text = point.Y.ToString();
IFeature pFeature = pFC.CreateFeature();
pFeature.Shape = point;//设置新建的元素为点元素
//对元素设置属性值:
pFeature.set_Value(pFeature.Fields.FindField("任务名称"), richTextBox2.Text);
pFeature.set_Value(pFeature.Fields.FindField("任务描述"), richTextBox3.Text);
pFeature.set_Value(pFeature.Fields.FindField("开始时间"), dateTimePicker1.Text);
pFeature.set_Value(pFeature.Fields.FindField("结束时间"), dateTimePicker2.Text);
pFeature.set_Value(pFeature.Fields.FindField("地点名称"), richTextBox9.Text);
pFeature.Store();
//数据库新增新元素
string sql = "insert into VolunTask(objectID,volName,remark,starTime,endTime,volAdd) values("+pFeature.get_Value( pFeature.Fields.FindField("OBJECTID"))+","+"'" + richTextBox2.Text + "','" + richTextBox3.Text + "','" + DateTime.Parse( dateTimePicker1.Text.Replace("/", "-")) + "','" + DateTime.Parse(dateTimePicker2.Text.Replace("/", "-")) + "','" + richTextBox9.Text + "')";
int i=SQL1.excute(sql);
if (i > 0)
{
MessageBox.Show("数据库VolunTask新增数据项成功!");
}
//停止编辑\n
pWorkspaceEdit.StopEditOperation();
pWorkspaceEdit.StopEditing(true);
axMapControl1.ActiveView.Refresh();//更新视窗
break;
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
5.6.6.2放大
private void 点击放大ToolStripMenuItem_Click(object sender, EventArgs e)
{
IEnvelope envelope = axMapControl1.Extent;
envelope.Expand(0.5, 0.5, true);
axMapControl1.Extent = envelope;
axMapControl1.Refresh();
}
private void 拉框放大ToolStripMenuItem_Click(object sender, EventArgs e)
{
function = "ZoomIn";
}
5.6.6.3缩小
private void 缩小ToolStripMenuItem_Click(object sender, EventArgs e)
{
IEnvelope envelope = axMapControl1.Extent;
envelope.Expand(1.5, 1.5, true);
axMapControl1.Extent = envelope;
axMapControl1.Refresh();
}
5.6.6.4全图
private void 全图ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.Extent = axMapControl1.FullExtent;
}
5.6.6.5漫游
private void 漫游ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.Pan();
}
5.6.6.6获取坐标点
private void 获取坐标点ToolStripMenuItem_Click(object sender, EventArgs e)
{
function = "coordinate";
}
5.6.6.7清除选择
private void 清除选择ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.Map.ClearSelection();
}
图5.24 要素
图5.25 要素功能栏
5.6.7.1拉框选择要素
private void 拉框选择要素ToolStripMenuItem_Click(object sender, EventArgs e)
{
function = "select";
}
5.6.7.2查看要素名称
private void 点击查看要素信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
IEnumFeature enumFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;
enumFeature.Reset();
feature = enumFeature.Next();
int i = 1;
string text = string.Empty;
while (feature != null)
{
int index = feature.Table.Fields.FindField("名称");
if (index > 0)
{
text += (i++) + " 所选要素名称:" + feature.get_Value(index).ToString() + "\n";
}
else
{
text += (i++) + " 无名称" + "\n";
};
feature = enumFeature.Next();
}
MessageBox.Show(text);
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
5.6.7.3获取要素
private void 获取要素ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
IEnumFeature enumFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;
enumFeature.Reset();
feature = enumFeature.Next();
axMapControl1.Map.ClearSelection();
for (int i = 0; i < axMapControl1.Map.LayerCount; i++)
{
try
{
ILayer layer = axMapControl1.get_Layer(i);
axMapControl1.Map.SelectFeature(layer, feature);
break;
}
catch {
axMapControl1.Map.ClearSelection();
}
}
int index = feature.Table.Fields.FindField("名称");
if (index > 0)
{
textBox22.Text = "所选要素名称:" + feature.get_Value(index).ToString();
}
else
{
textBox22.Text = "无名称";
};
switch (feature.Shape.GeometryType)
{
case esriGeometryType.esriGeometryPoint: MessageBox.Show("已获取该点要素," + textBox22.Text); break;
case esriGeometryType.esriGeometryPolygon: MessageBox.Show("已获取该多边形要素," + textBox22.Text); break;
case esriGeometryType.esriGeometryPolyline: MessageBox.Show("已获取该线要素," + textBox22.Text); break;
}
axMapControl1.Extent = feature.Extent;
yaosu();
yaosuTable();
axMapControl1.Refresh();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
5.6.7.4查看要素属性
private void 查看要素属性ToolStripMenuItem_Click(object sender, EventArgs e)
{
yaosu();
if (textBox22.Text == "所选要素")
{
获取要素ToolStripMenuItem_Click(获取要素ToolStripMenuItem, new EventArgs());
}
}
5.6.7.5修改要素属性
private void button17_Click(object sender, EventArgs e)
{
try
{
feature.set_Value(feature.Fields.FindField(comboBox5.Text), textBox23.Text);
yaosuTable();
feature.Store();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
public void yaosuTable()
{
DataTable yaosuT = new DataTable();
comboBox5.Items.Clear();
for (int i = 0; i < feature.Fields.FieldCount; i++)
{
string col = feature.Fields.Field[i].Name;
yaosuT.Columns.Add(col, typeof(String));
comboBox5.Items.Add(col);
}
DataRow dr = yaosuT.NewRow();
for (int i = 0; i < feature.Fields.FieldCount; i++)
{
string col = feature.Fields.Field[i].Name;
dr[col] = feature.get_Value(i);
}
yaosuT.Rows.Add(dr);
dataGridView2.DataSource = yaosuT;
}
private void yaosu()
{
tabControl8.SelectedIndex = 1;
tabControl9.SelectedIndex = 2;
}
5.6.7.6按属性sql查询并选择
private void button20_Click(object sender, EventArgs e)
{
try
{
IQueryFilter q = new QueryFilterClass();
q.WhereClause = richTextBox6.Text;
IFeatureSelection featureselection=featurelayer as IFeatureSelection;
featureselection.SelectFeatures(q, esriSelectionResultEnum.esriSelectionResultNew, false);
axLicenseControl1.Refresh();
获取要素ToolStripMenuItem_Click(获取要素ToolStripMenuItem, new EventArgs());
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
图5.26 图层
图5.27 图层功能栏
5.6.8.1获取
private void button11_Click(object sender, EventArgs e)
{
try
{
featurelayer = axMapControl1.get_Layer(Convert.ToInt32(textBox16.Text)) as IFeatureLayer;
MessageBox.Show("图层已获取,图层名为" + featurelayer.Name);
textBox18.Text = featurelayer.Name;
index = Convert.ToInt32(textBox16.Text);
button18_Click(button18,new EventArgs());
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void button12_Click(object sender, EventArgs e)
{
int i = findlayerByname(textBox18.Text);
if(i>-1)
{
MessageBox.Show("图层已获取,图层序号为" + i.ToString());
};
}
5.6.8.2查看属性表
///
/// 获得要素图层的属性表
///
/// 要素图层对象
///
public static DataTable GetDataTableFromFeatureLayer(IFeatureLayer pFeatureLayer)
{
if (pFeatureLayer == null)
{
return new DataTable();
}
IFields pFields = new Fields();
pFields = pFeatureLayer.FeatureClass.Fields;
DataTable pDataTable = new DataTable();
for (int i = 0; i < pFields.FieldCount; i++) //获得字段名
{
string fldName;
fldName = pFields.get_Field(i).AliasName;
pDataTable.Columns.Add(fldName);
}
IFeatureCursor pFeatureCursor;
pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false);
IFeature pFeature;
pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
string fldValue = null;
DataRow dr = pDataTable.NewRow();
for (int i = 0; i < pFields.FieldCount; i++)
{
string fldName;
fldName = pFields.get_Field(i).Name;
if (fldName == "Shape")
{
fldValue = Convert.ToString(pFeature.Shape.GeometryType);
}
else
{
fldValue = Convert.ToString(pFeature.get_Value(i));
}
dr[i] = fldValue;
}
pDataTable.Rows.Add(dr);
pFeature = pFeatureCursor.NextFeature();
}
return pDataTable;
}
private void checkshuxinT(object sender, EventArgs e)
{
tabControl8.SelectedIndex = 1;
tabControl9.SelectedIndex = 1;
DataTable shuxinT = GetDataTableFromFeatureLayer(featurelayer);
dataGridView3.DataSource = shuxinT;
}
5.6.8.3移动
private void button13_Click(object sender, EventArgs e)
{
try {
axMapControl1.MoveLayerTo(index, Convert.ToInt32(textBox17.Text));
axMapControl1.Refresh();
MessageBox.Show("已经成功移动图层到" + textBox17.Text+"层");
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
5.6.8.4删除
private void button14_Click(object sender, EventArgs e)
{
try
{
axMapControl1.DeleteLayer(index);
axMapControl1.Refresh();
MessageBox.Show("已经成功删除图层" + featurelayer.Name );
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
5.6.8.5可见性
private void button15_Click(object sender, EventArgs e)
{
try
{
featurelayer.Visible = !(featurelayer.Visible);
axMapControl1.Refresh();
MessageBox.Show(featurelayer.Visible.ToString());
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
5.6.8.6设置显示比例尺
private void button16_Click(object sender, EventArgs e)
{
try
{
featurelayer.MinimumScale = Convert.ToInt32(textBox19.Text);
featurelayer.MaximumScale = Convert.ToInt32(textBox20.Text);
MessageBox.Show("成功设置"+featurelayer.Name+"的显示比例尺范围");
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
图5.28 核酸检测功能栏
5.6.9.1新建核酸检测点
private void 新建核酸检测点ToolStripMenuItem_Click(object sender, EventArgs e)
{
hesuandian();
function = "createPoint";
}
5.6.9.2删除核酸检测点
private void 删除核酸检测点ToolStripMenuItem_Click(object sender, EventArgs e)
{
hesuandian();
findlayerByname("核酸检测点");
button11_Click(button11, new EventArgs());
}
在工具条Network Analyst下首先新建路径后,再创建俩个停留点,最后点击Solve,即可进行路径分析。
图5.29 路径分析举例1
图5.30 路径分析举例2
数据安全有对立的两方面的含义:一是数据本身的安全,主要是指采用现代密码.算法对数据进行主动保护,如数据保密、数据完整性、双向强身份认证等,二是数据防护的安全,主要是采用现代信息存储手段对数据进行主动防护,如通过磁盘阵列、数据备份、异地容灾、防火墙防止攻击等手段保证数据的安全,数据安全是一种主动的包含措施,数据本身的安全必须基于可靠的加密算法与安全体系,主要是有对称算法与公开密钥密码体系两种。数据信息安全不仅是单一-电脑的问题,也不仅是服务器或路由器的问题,而是整体网络系统的问题。所以信息安全要考虑整个网络系统,结合网络系统来制定合适的信息安全策略。由于网络安全涉及到的问题非常多,如防病毒、防人侵破坏、 防信息盗窃、用户身份验证等,这些都不是由单- 产品来完成,也不可能由单-产品来完成,最重要的是,各种各样的单位产品堆砌依然无法给予数据信息安全完整的保护。数据信息安全也必须从整体策略来考虑,采用功能完善、技术强大的数据信息安全保障系统。所以在对数据安全的方案上,我们会对数据本身以及数据存储服务器进行一些防护机制,确保数据安全。
本软件中我采用了以下方法进行数据安全保护:
1.将数据库中的人员账号表、人员密码表、人员的个人信息表分开存储,只是通过外键相连,保证了信息的独立性,无法通过其中一张表的内容获取其他表的内容。
2.志愿者表,管理员表,检测者表以及普通人员表的主键都不同,但都与人员ID有关。分割了信息链接,保证了数据安全。、
3.进行权限设计,拥有更高权限才能对数据库进行更高级的操作,避免的数据错误。
4.管理员可在该软件中导出数据,进行数据备份,恢复数据。
上一篇:美国学生抗议活动,揭示美媒不敢提的“公开秘密”…… 美国学生抗议会不会引发战争 美国学生抗议行动说明什么
下一篇:半场-青岛西海岸0-2南通支云 西海岸后防两次失误戈迪内斯双响 青岛西海岸队将战南通支云 戈迪内斯南通支云为什么没有上场