空气质量监测管理系统
一、语言和环境
A、实现语言
C#,WinForms
B、环境要求
Visual Studio 2012,SQL Server 2008
二、功能要求
使用 Visual Studio 2012 实现空气质量监测管理功能,SQL Server 2008 作为
后台数据库,程序界面采用 MDI 窗体风格,主菜单包括菜单项:“录入监测数据”、“查
询监测结果”和“退出”,学员需完成这三个功能;
三、实现代码
1、录入监测数据
private void buttonclose_Click(object sender, EventArgs e)
{
//关闭
this.Close();
}
private void buttonsubmit_Click(object sender, EventArgs e)
{
//提交
if( refer()){
SqlConnection conn = new SqlConnection(constr);
conn.Open();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("insert into dbo.irQualityInfo(StationID,InputName,StartDate,EndDate,PM,Level,Notes)");
sb.AppendFormat(" values");
sb.AppendFormat("( '{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
cmbStationID.SelectedValue,
textInputName.Text,
textStartDate.Text,
textEndDate.Text,
textPM.Text,
textLevel.Text,
textNotes.Text );
SqlCommand cmd = new SqlCommand(sb.ToString(),conn);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("数据保存成功");
}
else {
MessageBox.Show("保存失败"