当前位置:首页 > 毕业设计说明书 计算机
淮阴师范学院毕业论文(设计)
图5-4-1
主代码如下:
SqlConnection cn = BaseClass.DBConn.CyCon(); DataSet ds = new DataSet(); private string txt = \;
private void display() {
SqlCommand cmd = new SqlCommand();
cmd.CommandText = string.Format(\课程号,课程名,学分 from 选课信息 where 教工号 ='{0}'\, login.userid.Trim()); cmd.Connection = cn;
SqlDataAdapter adapter = new SqlDataAdapter(cmd); ds.Clear();
adapter.Fill(ds, \);
dataGridView1.DataSource = ds.Tables[\]; }
private void display1() {
comboBox1.Items.Clear();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = string.Format(\(select 课程名 from 选课信息,course where 选课信息.课程号=course.cno and 教工号='{0}')\, login.userid.Trim()); cmd.Connection = cn; cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
25
淮阴师范学院毕业论文(设计)
while (dr.Read()) {
comboBox1.Items.Add(dr[0].ToString()); }
cn.Close(); dr.Close(); }
private void teacourseinfo_Load(object sender, EventArgs e) {
display();
display1(); }
private void button1_Click(object sender, EventArgs e) {
SqlCommand cmd = new SqlCommand();
txt = dataGridView1.CurrentRow.Cells[0].Value.ToString();
cmd.CommandText = string.Format(\and cno='{1}' \,login.userid.Trim(),txt); cmd.Connection = cn; try {
cn.Open();
cmd.ExecuteNonQuery();
toolStripStatusLabel1.Text=\您以后将不再受理此课程!\;
}
catch(SqlException ex) {
toolStripStatusLabel1.Text=\错误:\+ex.Message; }
finally {
cn.Close(); }
display(); display1(); }
26
淮阴师范学院毕业论文(设计)
private void button2_Click(object sender, EventArgs e) {
string cno=\;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = string.Format(\cname='{0}'\,comboBox1.Text.Trim()); cmd.Connection = cn; cn.Open();
SqlDataReader dr = cmd.ExecuteReader(); if(dr.Read()) {
cno=dr[0].ToString(); }
cn.Close(); dr.Close(); /* */
string str = string.Format(\into teach values('{0}','{1}') \, login.userid.Trim(), cno.ToString()); cmd = new SqlCommand(str,cn); try {
cn.Open();
cmd.ExecuteNonQuery();
toolStripStatusLabel1.Text=\申请授课成功!\;
}
catch (SqlException ex) {
toolStripStatusLabel1.Text=\错误:\ + ex.Message; }
finally {
cn.Close(); }
//BaseClass.DBConn.getsqlcmd(\
values('\ display(); display1(); }
27
淮阴师范学院毕业论文(设计)
学生、教师信息的查询显示界面如图5-4-2所示。教师信息界面与学生类似,这里就举学生界面为例。
图5-4-2学生信息
主代码如下:
SqlConnection cn = new SqlConnection(\
Source=WS03-20111120UM;Initial Catalog=design;Integrated Security=True\); DataSet ds;
SqlDataAdapter adapter; private static int n;
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) {
string sql = \学号,sname 姓名,sage 年龄,entertime 入学时间,sdept 系科 from student where sdept='\ + e.Node.Text.ToString() + \;
adapter = new SqlDataAdapter(sql, cn); ds = new DataSet(); ds.Clear();
if (cn.State == ConnectionState.Closed) cn.Open();
adapter.Fill(ds, \);
dataGridView1.DataSource = ds.Tables[\]; cn.Close(); }
private void dataGridView1_CellContentClick(object sender,
28
共分享92篇相关文档