学员管理系统。

pingdanshizhen 2008-03-21 07:53:43
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace Student
{
public partial class Most : Form
{
List<student> list = new List<student>();
public Most()
{
InitializeComponent();
}

private void butAdd_Click(object sender, EventArgs e)
{
student st = new student();
st.ID1 = Convert.ToInt32(this.txtID.Text);
st.Name = this.txtName.Text;
st.Sex = this.cboSex.Text;
st.Age = Convert.ToInt32(this.txtAge.Text);
st.Score = Convert.ToInt32(this.txtScore.Text);
st.Address = this.txtAddress.Text;
list.Add(st);
this.listBox1.Items.Add("学号:" + this.txtID.Text);
this.listBox1.Items.Add("姓名:" + this.txtName.Text);
this.listBox1.Items.Add("性别:" + this.cboSex.Text);
this.listBox1.Items.Add("年龄:" + this.txtAge.Text);
this.listBox1.Items.Add("成绩:" + this.txtScore.Text);
this.listBox1.Items.Add("地址:" + this.txtAddress.Text);
this.txtID.Clear();
this.txtName.Clear();
this.cboSex.Enabled = false;
this.txtAge.Clear();
this.txtScore.Clear();
this.txtAddress.Clear();
//this.cboSex.Enabled = true;
}

private void butShanchu_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
this.butAdd.Enabled = true;

}



private void txtID_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)))
{
MessageBox.Show("输入只能为数字","提示");
e.Handled = true;
}
}

private void txtAge_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)))
{
MessageBox.Show("输入只能为数字", "提示");
e.Handled = true;
}
}

private void txtScore_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)))
{
MessageBox.Show("输入只能为数字", "提示");
e.Handled = true;
}
}

private void butXiugai_Click(object sender, EventArgs e)
{
string str = this.listBox1.SelectedItem.ToString();
this.listBox1.Items.Remove(str);
this.listBox1.Items.Add(this.txtUp.Text);
if (MessageBox.Show("是否修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.txtUp.Text = "";
}
}

private void butQueren_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
FileStream fs = new FileStream("Student.bin", FileMode.OpenOrCreate);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, list);
MessageBox.Show("保存成功!");
fs.Close();
this.cboSex.Enabled = true;
}

private void Most_Load(object sender, EventArgs e)
{

}

private void butClose_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
FileStream fs = new FileStream("Student.bin",FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
List<student> l = (List<student>)bf.Deserialize(fs);
foreach (student stu in l)
{
string s = "";
s += "学号:" + stu.ID1 + "姓名:" + stu.Name + "性别:" + stu.Sex + "年龄:" + stu.Age + "成绩:" + stu.Score + "地址:" + stu.Address;
this.listBox1.Items.Add(s);
}
fs.Close();
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
for (int count = 0; count < this.listBox1.SelectedItems.Count;count++ )
{
this.txtUp.Text = Convert.ToString(this.listBox1.SelectedItems[count]);
}
}
//查询
private void butChanxun_Click(object sender, EventArgs e)
{

}

private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
该系统没连数据库,用的是序列化和反序列化,请问该查询语句怎样写啊(根据学号和姓名来进行查询)

...全文
96 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
k19791 2008-03-21
  • 打赏
  • 举报
回复
低价转让:中#美#爱#梯#科技.Net软件工程师培训课程内容(共35G),声音清晰,课程完整!
需要这个培训视频的朋友请联系 QQ 936652114
春天的气息 2008-03-21
  • 打赏
  • 举报
回复
一样要用SQL语句呀,不过把TXT文件作为数据库的。相关内容网上搜一下就OK了。
dancingbit 2008-03-21
  • 打赏
  • 举报
回复
没用数据库就不需要写查询语句。

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧