用vs2010建立简单的查询功能
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
用vs2010建立简单的查询功能
using System;
using System.Collections.Generic;
using ponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public struct student
{
public string name;
public string sno;
public string class1;
public string tel;
public string addr;
};
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e) {
}
private void button1_Click(object sender, EventArgs e)
{
int i = 0;
string name;
name = textBox1.Text;
student[] stu = new student[5];
stu[0].name = "李?冰括?冰括?;
stu[0].sno = "2013064001";
stu[0].class1 = "影 ?视酣?41班悒?;
stu[0].tel = "12345678911";
stu[0].addr = "黑ú龙ⅷ?江-省?哈t尔?滨?市篋五?常£市篋";
stu[1].name = "范?冰括?冰括?;
stu[1].sno = "201302101";
stu[1].class1 = "影 ?视酣?51班悒?;
stu[1].tel = "12365498712";
stu[1].addr = "山?东?青à岛蘯";
stu[2].name = "赵?丽?颖 ?;
stu[2].sno = "2013098989";
stu[2].class1 = "影 ?视酣?81班悒?;
stu[2].tel = "98765432198";
stu[2].addr = "河ó北馈?省?廊え?坊?市篋";
stu[3].name = "何?炅酣?;
stu[3].sno = "301206515";
stu[3].class1 = "播¥音?881班悒?;
stu[3].tel = "23654987121";
stu[3].addr = "湖t南?省?长¤沙?市篋";
stu[4].name = "范?冰括?冰括?;
stu[4].sno = "20126556";
stu[4].class1 = "软â?卓?88班悒?;
stu[4].tel = "78945632156";
stu[4].addr = "广?西ô玉?林?";
int flag = 1;
for (i = 0; i < 5; i++)
{
if (stu[i].name == name)
{
label2.Text += ("查ã询ˉ结á果?:\n" + "学§号?:阰" + stu[i].sno + "\n" + "班悒?级?:阰" + stu[i].class1 + "\n" + "手?机ú号?码?:阰" + stu[i].tel + "\n"
+ "家ò庭 ?住?址·:阰" + stu[i].addr + "\n");
flag=0;
}
}
if (flag == 1)
{
MessageBox.Show("不?存?在ú该?学§生Θ?的?信?息¢!?请?重?新?输?入?:阰"); }
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
label1.Focus();
label2.Text = "";
}
}
}