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

失物查询系统(4)

来源:网络收集 时间:2019-03-28 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

6 程序源代码说明书

6.1 程序源代码 6.1.1 主界面代码:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

namespace LostQuery {

public partial class Main : Form {

public Main() {

InitializeComponent(); }

// “登记/修改” 按钮的响应

private void btn_input_Click(object sender, EventArgs e) {

Login login = new Login(); login.Show(); }

//“查询”按钮的响应

private void btn_query_Click(object sender, EventArgs e) {

Query query = new Query(); query.Show(); } } }

6.1.2 登录 页面代码:

using System;

11

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms;

namespace LostQuery {

public partial class Login : Form {

public Login() {

InitializeComponent(); }

//“登录”按钮添加响应

private void btn_login_Click(object sender, EventArgs e) {

//判断是否输入为空

if (this.tb_account.Text == \ || this.tb_password.Text == \) {

MessageBox.Show(\请输入用户名和密码\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information);

this.tb_account.Focus(); this.tb_password.Focus(); } else {

//用户名和密码输入正确

if (this.tb_account.Text == \ && this.tb_password.Text == \) {

Input input = new Input(); input.Show(); this.Visible = false; }

//用户名或密码不正确 else {

MessageBox.Show(\对不起,你输入的用户名或密码不正确,不能进行登记\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information);

12

this.tb_account.Focus(); this.tb_password.Focus(); } } }

//“清除”按钮添加响应

private void btn_clear_Click(object sender, EventArgs e) {

tb_account.Clear(); tb_password.Clear(); } } }

6.1.3 登记/修改 页面代码:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

using System.Text.RegularExpressions;

namespace LostQuery {

public partial class Input : Form {

public Input() {

InitializeComponent(); }

/*****************************************************************************/ /* 登记新的失物信息模块 */ /*****************************************************************************/

//给确定按钮添加响应

13

private void btnOk_Click(object sender, EventArgs e) {

//失物类型不允许为空 if (this.tbType.Text == \)

MessageBox.Show(\请输入失物类型\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); else {

//把失物信息写入数据库 string connString =

\Security=True\;//新建connection对象

SqlConnection connection = new SqlConnection(connString);

string sqlString = \

listLost(type,feature,lostLocation,date,status) values('\ + tbType.Text.Trim() + \ + tbFeature.Text.Trim() + \ + tbAddress.Text.Trim() + \ +

dateTimePicker1.Value.ToShortDateString() + \未领取')\;//登记的物品状态都设置为未领取 try {

connection.Open();

MessageBox.Show(\打开数据库连接成功\);

SqlCommand command = new SqlCommand(sqlString, connection); int result = command.ExecuteNonQuery(); MessageBox.Show(\添加成功\); }

catch (Exception) {

MessageBox.Show(\打开失败\); } finally {

connection.Close();

MessageBox.Show(\关闭数据库连接成功\); } } }

//“清除”按钮添加响应

private void btnClear_Click(object sender, EventArgs e) {

tbType.Clear();

14

tbFeature.Clear(); tbAddress.Clear(); }

/*****************************************************************************/ /* 修改状态模块 */ /*****************************************************************************/

//“确定”按钮添加响应

private void buttonOK_Click(object sender, EventArgs e) {

//输入为空

if (this.tbGet.Text == \)

MessageBox.Show(\请输入领取编号!\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); else {

//判断输入的是不是数字

string isNum = this.tbGet.Text;

Regex reg = new Regex(\); //判断是不是数据,要不是就表示没有选择,则从隐藏域里读出来

Match ma = reg.Match(isNum); if (ma.Success) {

int num = Convert.ToInt32(isNum); //是数字

string connString =

\Security=True\;//新建connection对象

SqlConnection connection = new SqlConnection(connString);

string sqlString = \已领取' where id='\+num+\;

try {

connection.Open();

MessageBox.Show(\打开数据库连接成功\);

SqlCommand command = new SqlCommand(sqlString, connection); int result = command.ExecuteNonQuery(); MessageBox.Show(\状态更改成功\); }

15

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库失物查询系统(4)在线全文阅读。

失物查询系统(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/549196.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: