嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
可以对学生进行增删查改操作~非常方便快捷,含数据库
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApp1
{
public partial class SelectstuInfo : Form
{
private const string caption= "操作提示!";
public SelectstuInfo()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
FillFistView();
}
private void FillFistView()
{
if (listView1.Items.Count > 0)
{
listView1.Items.Clear();
}
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT S.[StudentNo],S.[StudentName],S.[Sex],G.[GradeName]");
sql.AppendLine("FROM Student AS S,Grade AS G");
sql.AppendLine("WHERE S.[GradeId]=G.[GradeId]");
sql.AppendFormat("AND S.[StudentName] LIKE '%{0}%'", this.textBox1.Text.Trim());
DBHelper db = new DBHelper();
try
{
SqlCommand command = new SqlCommand(sql.ToString(), db.Connection);
db.OpenConnection();
SqlDataReader reader = command.ExecuteReader();
if (!reader.HasRows)
{
MessageBox.Show("没有要查找的记录!", caption, MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
while (reader.Read())
{
string studentNo = reader["StudentNo"].ToString();
string studentName = reader["StudentName"].ToString();
string genderId = reader["Sex"].ToString();
if (genderId.Equals("男"))
{
genderId = "男";
}
else
{
genderId = "女";
}
string gradeName = reader["GradeName"].ToString();
ListViewItem item = new ListViewItem(studentNo);
item.SubItems.Add(studentName);
item.SubItems.Add(genderId);
item.SubItems.Add(gradeName);
listView1.Items.Add(item);
}
}
reader.Close();
}
catch (Exception)
{
MessageBox.Show("系统出现错误!", caption, MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
db.CloseConnection();
}
}
private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.listView1.SelectedItems.Count > 0)
{
EditSchoolinfo edit = new EditSchoolinfo();
edit.studentNo =this.listView1.SelectedItems[0].Text;
edit.MdiParent = this.MdiParent;
edit.Show();
}
else
{
MessageBox.Show("请选择一个学生!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void SelectstuInfo_Load(object sender, EventArgs e)
{
}
}
}