1. 程式人生 > >學生管理系統設計(資料庫連線C#版)

學生管理系統設計(資料庫連線C#版)

目錄
一.課程設計說明 1
1.1專案概述 1
1.2設計任務和要求 1
1.3開發環境說明 1
二.需求分析階段 1
2.1專案介紹 2
2.2資料需求分析 2
三.概念結構設計 3
3.1E-R圖 4
3.2資料庫設計 5
3.3資料字典 8
四.使用者介面設計 11
4.1學生資訊管理系統 12
4.2學生資訊查詢 12
4.3教師查詢 12
4.4管理員查詢 12
4.5專業負責人查詢 13
五.程式設計 14
六.執行結果 28
七.總結

一.課程設計說明

1.1專案概述:
學生管理系統
一所大學希望建立一個數據庫以便對學生進行管理。當一個學生進入學校時,他就會選擇一個專業。每個學生也會指定一個指導老師。每個專業每年由一些課程組成。組成專業的課程的最小和最大數目分別是6和8。一般情況下給一個學生三次機會來通過這門課程的考試。有些特殊的課程可以在一個或多個專業中存在。大學可以有幾個部門,每個部門都有一個部門負責人,每個課程都會分配一定數量的員工(稱為課程合作人)來負責課程的教學
1.2設計任務與要求
建立資料庫,來完成對學生進行管理的目的,要求要按照題目設定,包括學生、教師、管理員的學生管理系統的設計與開發。

1.3開發環境說明
採用SQL SERVER和Visual Studio 來進行系統開發。
二.功能需求分析階段
2.1專案介紹
學生管理系統在學生方面,新生在校註冊,註冊時選擇專業,從而學校分配指導教師完成在校學習的課程,學生也可通過學生管理系統查詢個人資訊,包括個人選修課資訊,考試資訊等。
在教師方面,教師可以通過學生管理系統查詢任教的課程資訊,以及對學生的考試成績的錄入。
在管理員方面,管理員可以通過管理員許可權查詢、增加、刪除、修改所有資訊。
2.2資料需求分析

這裡寫圖片描述
總結如下:
這裡寫圖片描述
2.3資料處理與任務需求
下面列出的是學生管理資料庫應用應該支援的事務。

(1) 資料應該能夠支援下述維護事務。
a) 建立和維護學校內學生的詳細資訊。
b) 建立和維護學校內教師的詳細資訊。
c) 建立和維護學校內課程的詳細資訊。
(2) 資料應該能夠支援下述查詢事務
a) 以報表形式列出學生的姓名,學號及其他詳細資訊
b) 以報表形式列出專業的名稱、專業號及其他詳細資訊
c) 以報表形式列出課程的名稱、課程號及其他詳細資訊
d) 列出某一給定學生的課程及成績
e) 列出某一專業的課程資訊
三、概念結構設計
3.1E-R圖的分析和設計
這裡寫圖片描述

3.2資料庫邏輯設計
ER圖和關係模式的轉化

這裡寫圖片描述

3.3資料字典

實體簡介
學生(學號,姓名,性別,出生日期,民族,所在專業編號,指導教師編號,電話號碼,家庭地址,資訊備註)
課程(課程號,課程名,學分)
專業(專業號,專業名,專業負責人號)
教職工(教師號,姓名,性別,出生日期,民族,所在專業編號,職稱,電話,家庭地址,資訊備註)

專業課設表(專業號、課程號)
考試(課程號,學號,成績,考試次數)
使用者(使用者編號,使用者密碼,使用者類別)
(1) 學生表Student細節
這裡寫圖片描述

(2) 4.2教師個人資訊表TEACHER(教師號TNO,姓名TNAME,性別TSEX,出生日期TBIRTHDAY,名族TNATIVE,所在專業編號TDEPTNO,職稱TPOSITION,電話STEL,家庭住址SADDRESS,備註資訊SNOTE)
這裡寫圖片描述

(3) 4.3專業表MAJOR(專業號MNO,專業名MNAME,專業負責人編號MTEACHER)
這裡寫圖片描述

(4) 4.4課程表 COURSE(課程號CNO,課程名CNAME,學分CGRADE
授課教師CTEACHER)
這裡寫圖片描述

(5) 4.5成績表SC(學生號SNO,課程號CNO,成績SCGRADE)
這裡寫圖片描述

(6) 4.6專業課設表MC(專業號MNO,課程號CNO)
屬性名 欄位型別 長度 主鍵或外來鍵 說明
這裡寫圖片描述

(7) 4.7使用者表YONGHU(使用者編號YNO,使用者密碼YMIMA,使用者類別LEIBIE)
這裡寫圖片描述

四、使用者介面設計

4.1學生資訊管理系統

4.2學生資訊查詢

4.3教師查詢

4.4管理員查詢

4.5專業負責人查詢

五、程式設計
原始碼

FORM1//學生資訊管理系統

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 學生管理系統
{
publicpartialclassForm1 : Form
    {
SqlConnection conn = newSqlConnection("Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True");

staticpublicstring sn, sub;
public Form1()
        {
            InitializeComponent();
        }
Form2 fr2 = newForm2(); Form3 fr3 = newForm3(); Form4 fr4 = newForm4(); Form5 fr5 = newForm5();


privatevoid button1_Click_1(object sender, EventArgs e)
        {
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open();
if (textBox1.Text == "" || textBox2.Text == "")
MessageBox.Show("請不要遺漏資訊!");
if (radioButton1.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='管理員'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                {
                    sn = textBox1.Text.Trim();
Form4 fm = newForm4();
                    fm.Show();
                    fr4.Show(); this.Visible = false;
                }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
if (radioButton2.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='教師'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr3.Show(); this.Visible = false; }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
if (radioButton3.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='學生'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr2.Show(); this.Visible = false; }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
if (radioButton4.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='專業負責人'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr5.Show(); this.Visible = false; }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
            conn.Close(); conn.Dispose();
        }



privatevoid button2_Click_1(object sender, EventArgs e)
        {
Application.Exit();
        }

privatevoid radioButton4_CheckedChanged(object sender, EventArgs e)
        {
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open();
string cstr = "select * from YONGHU where LEIBIE='學生'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
            {
if (dr.Read())
                {
                    sn = textBox1.Text.Trim();
                    fr2.Show();
this.Visible = false;
                }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
            conn.Close(); conn.Dispose();
        } 

privatevoid radioButton3_CheckedChanged(object sender, EventArgs e)
        {    
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open(); 
string cstr = "select * from YONGHU where LEIBIE='教師'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
            {
if (dr.Read())
                { sn = textBox1.Text.Trim(); 
                    fr3.Show(); 
this.Visible = false; 
                }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
            conn.Close(); conn.Dispose();
        }
privatevoid radioButton2_CheckedChanged(object sender, EventArgs e)
        {
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open(); 
string cstr = "select * from YONGHU where LEIBIE='專業負責人'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr5.Show(); this.Visible = false; }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
                conn.Close(); 
            }

privatevoid radioButton1_CheckedChanged(object sender, EventArgs e)
        {  
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open(); 
string cstr = "select * from YONGHU where LEIBIE='管理員'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);

SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr4.Show(); this.Visible = false; }
else
                {
MessageBox.Show("輸入有誤,請重新輸入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
                conn.Close(); 
        }
        }

    }

FORM2//學生資訊查詢

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 學生管理系統
{
publicpartialclassForm2 : Form
    {
public Form2()
        {
            InitializeComponent();
        }



privatevoid button4_Click(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox2.Text + "'," + "LEIBIE='" + textBox3.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid 查詢成績_Click(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open(); 
if (Form1.sn.Trim() == "001")
            {
                adapter = newSqlDataAdapter("select SC.SNO 學號,SC.CNO 課程號,SCGRADE1 成績1,SCGRADE2 成績2,SCGRADE3 成績3  from SC WHERE SNO=001", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "002")
            {
                adapter = newSqlDataAdapter("select SC.SNO 學號,SC.CNO 課程號,SCGRADE1 成績1,SCGRADE2 成績2,SCGRADE3 成績3  from SC WHERE SNO=002", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "003")
            {
                adapter = newSqlDataAdapter("select SC.SNO 學號,SC.CNO 課程號,SCGRADE1 成績1,SCGRADE2 成績2,SCGRADE3 成績3  from SC WHERE SNO=003", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid 查詢個人資訊_Click(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (Form1.sn.Trim() == "001")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 學號,SNAME 姓名,SSEX 性別,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 電話,SADDRESS 家庭住址,SNOTE 備註資訊 from STUDENTS WHERE   SNO=001",conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "002")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 學號,SNAME 姓名,SSEX 性別,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 電話,SADDRESS 家庭住址,SNOTE 備註資訊 from STUDENTS WHERE   SNO=002",conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "003")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 學號,SNAME 姓名,SSEX 性別,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 電話,SADDRESS 家庭住址,SNOTE 備註資訊 from STUDENTS WHERE   SNO=003",conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button3_Click(object sender, EventArgs e)
        {
this.Close();
Form1 f1 = newForm1();
            f1.Show();
        }
    }
}
FORM3  //教師查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 //學生管理系統
{
publicpartialclassForm3 : Form
    {
public Form3()
        {
            InitializeComponent();
        }
privatevoid Form3_Load(object sender, EventArgs e)
        {
            學號.Text = Form1.sn + "教師,歡迎使用本管理系統!";


        }



privatevoid 學號_Click(object sender, EventArgs e)
        {

        }

privatevoid button3_Click(object sender, EventArgs e)
        {
DataTable table;
SqlDataAdapter adapter;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox1.Text == "001")
            {
                adapter = newSqlDataAdapter("select SC.SNO 學號, SC.CNO 課程號,SCGRADE1 成績1,SCGRADE2 成績2,SCGRADE3 成績3 from SC WHERE  SC.SNO=001 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "002")
            {
                adapter = newSqlDataAdapter("select * from SC WHERE  SC.SNO=002", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "003")
            {
                adapter = newSqlDataAdapter("select SC.SNO 學號, SC.CNO 課程號,SCGRADE1 成績1,SCGRADE2 成績2,SCGRADE3 成績3 from SC WHERE  SC.SNO=003  ", conn); ;
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }

        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
Form1 f1 = newForm1();
            f1.Show();
this.Close();
        }

privatevoid button5_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox7.Text + "'," + "LEIBIE='" + textBox8.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid button1_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (Form1.sn.Trim() == "201")
            {
                adapter = newSqlDataAdapter("select * from TC,TEACHER WHERE TEACHER.TNO=201 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "202")
            {
                adapter = newSqlDataAdapter("select * from TC,TEACHER WHERE TEACHER.TNO=202 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "203")
            {
                adapter = newSqlDataAdapter("select * from TC,TEACHER WHERE TEACHER.TNO=203 ", conn); ;
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }


        }

privatevoid button4_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  SC SET SNO='" + textBox1.Text + "',CNO='" + textBox2.Text + "',SCGRADE1='" + textBox3.Text + "',SCGRADE2='" + textBox4.Text + "',SCGRADE3='" + textBox5.Text + "'where SNO='" + textBox1.Text + "'and CNO='" + textBox2.Text + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");


        }

privatevoid Form3_Load_1(object sender, EventArgs e)
        {

        }

privatevoid textBox6_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox7_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox8_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox2_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox3_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox5_TextChanged(object sender, EventArgs e)
        {

        }
    }
    }

M4 //管理員

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 //學生管理系統
{
publicpartialclassForm4 : Form
    {
public Form4()
        {
            InitializeComponent();
        }
privatevoid Form4_Load(object sender, EventArgs e)
        {
            label1.Text = Form1.sn + "管理員,歡迎使用本管理系統!";
        }
privatevoid label19_Click(object sender, EventArgs e)
        {
        }
privatevoid button5_Click(object sender, EventArgs e)
        {
Form1 f1 = newForm1();
            f1.Show();
this.Close();
        }
privatevoid button6_Click(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YNO='" + textBox21.Text + "'," + "YMIMA='" + textBox22.Text + "'," + "LEIBIE='" + textBox23.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }
privatevoid button3_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlCommand cmd1 = conn.CreateCommand();
string AddString = "INSERT INTO STUDENTS  VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')";
string AddString1 = "INSERT INTO YONGHU  VALUES('" + textBox1.Text + "','" + textBox1.Text + "','" + "學生" + "')";
            cmd.CommandText = AddString;
            cmd1.CommandText = AddString1;
            cmd.ExecuteNonQuery();
            cmd1.ExecuteNonQuery();
MessageBox.Show("註冊成功!");
            conn.Close();
        }

privatevoid label10_Click(object sender, EventArgs e)
        {

        }

privatevoid label8_Click(object sender, EventArgs e)
        {

        }

privatevoid dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

privatevoid label1_Click(object sender, EventArgs e)
        {

        }

privatevoid groupBox1_Enter(object sender, EventArgs e)
        {

        }

privatevoid button1_Click_1(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox1.Text == "001")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 學號,SNAME 姓名,SSEX 性別,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 電話,SADDRESS 家庭住址,SNOTE 備註資訊 from STUDENTS WHERE   SNO=001", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "002")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 學號,SNAME 姓名,SSEX 性別,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 電話,SADDRESS 家庭住址,SNOTE 備註資訊 from STUDENTS WHERE   SNO=002", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "003")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 學號,SNAME 姓名,SSEX 性別,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 電話,SADDRESS 家庭住址,SNOTE 備註資訊 from STUDENTS WHERE   SNO=003", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();

if (textBox11.Text == "202")
            {
                adapter = newSqlDataAdapter("select TNO 教師號,TNAME 教師名,TSEX 性別,TBIRTHDAY 出生年份,TNATIVE 名族,TPOSITION 職稱,TTEL 電話,TADDRESS 家庭住址,TNOTE 備註資訊 from TEACHER WHERE TNO=202", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox11.Text == "203")
            {
                adapter = newSqlDataAdapter("select TNO 教師號,TNAME 教師名,TSEX 性別,TBIRTHDAY 出生年份,TNATIVE 名族,TPOSITION 職稱,TTEL 電話,TADDRESS 家庭住址,TNOTE 備註資訊 from TEACHER WHERE  TNO=203", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox2_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox3_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox5_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox6_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox7_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox8_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox9_TextChanged(object sender, EventArgs e)
        {

       }
privatevoid textBox10_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid button4_Click(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlCommand cmd1 = conn.CreateCommand();
string AddString = "INSERT INTO TEACHER  VALUES('" + textBox11.Text + "','" + textBox12.Text + "','" + textBox13.Text + "','" + textBox14.Text + "','" + textBox15.Text + "','" + textBox16.Text + "','" + textBox17.Text + "','" + textBox18.Text + "','" + textBox19.Text + "','" + textBox20.Text + "')";
string AddString1 = "INSERT INTO YONGHU  VALUES('" + textBox11.Text + "','" + textBox11.Text + "','" + "教師" + "')";
            cmd.CommandText = AddString;
            cmd1.CommandText = AddString1;
            cmd.ExecuteNonQuery();
            cmd1.ExecuteNonQuery();
MessageBox.Show("註冊成功!");
            conn.Close();
        }

privatevoid textBox11_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox12_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox13_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox14_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox15_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox16_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox17_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox18_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox19_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox20_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid button5_Click_1(object sender, EventArgs e)
        {
this.Close();
        }

privatevoid button6_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox22.Text + "'," + "LEIBIE='" + textBox23.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid textBox22_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox23_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

namespace 學生管理系統
{
publicpartialclassForm5 : Form
    {
public Form5()
        {
            InitializeComponent();
        }


privatevoid Form5_Load(object sender, EventArgs e)
        {
            label1.Text = Form1.sn + "專業負責人,歡迎使用本管理系統!";
        }

privatevoid button5_Click(object sender, EventArgs e)
        {

        }

privatevoid Form5_Load_1(object sender, EventArgs e)
        {

        }

privatevoid label4_Click(object sender, EventArgs e)
        {

        }

privatevoid groupBox1_Enter_1(object sender, EventArgs e)
        {

        }
privatevoid button1_Click_1(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox4.Text == "401")
            {
                adapter = newSqlDataAdapter("select * from COURSE WHERE CNO=401", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button6_Click(object sender, EventArgs e)
        {

SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox2.Text + "'," + "LEIBIE='" + textBox3.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid button4_Click_1(object sender, EventArgs e)
        {
this.Close();
Form1 f1 = newForm1();
            f1.Show();
        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox5.Text == "001")
            {
                adapter = newSqlDataAdapter(
            
           

相關推薦

學生管理系統設計資料庫連線C#

目錄 一.課程設計說明 1 1.1專案概述 1 1.2設計任務和要求 1 1.3開發環境說明 1 二.需求分析階段 1 2.1專案介紹 2 2.2資料需求分析 2 三.概念結構設計 3 3.1E-R圖 4 3.2資

後臺許可權管理系統設計圖文教程

後臺許可權管理系統設計(圖文教程) 作者:橘子洲頭 全文共 2210 字 5 圖,閱讀需要 6 分鐘 參考:原文連結 ———————— / BEGIN / ———————— 在人人都是產品經理的網站上蟄居了4年,學習了四年,由於最近的工

python寫的簡答學生管理系統Demo練習python語法

python寫的簡單的學生管理系統,練習python語法。 可以執行在windows和linux下,python 2.7。 #!/usr/local/bin/python # -*- coding:utf-8 -*- import os import re #定義學生

常見的幾種排序演算法java和C++參考《演算法》

博主這裡要講的幾種排序演算法包括(從難到易):1.氣泡排序(最low的演算法) 2.插入排序 3.希爾排序 4.歸併排序 5.快速排序 6.快速排序的三項切分 氣泡排序: (1)簡介:這是最原始,最簡單的排序,幾乎不需要額外的空間 (2)基本原理:通過迴圈將最大的元素移到

列印自身的程式python和c

python版 me='me=%r\nprint me %% me' print me % me 網上流傳的c版 #include <stdio.h> char* recurse = "#include <stdio.h>%cchar* rec

C/S模型-多程序-簡易學生-管理系統資料庫

簡介: 【1】資料:   學生資訊:姓名name + 賬號account + 分數score   登入資訊:賬號account + 密碼password(學生、管理員) 【2】C/S模型,使用fork實現多程序互動 【3】Client:   1)登入:學生登入,管理員登陸   2)管理員:修改密

Django學習筆記008-學生管理系統Django實現-查詢資料庫

資料庫配置: DATABASES = { 'default': { ##資料庫引擎 'ENGINE': 'django.db.backends.mysql', ##資料庫主機地址 'HOST': '127.0.0.1',

學生管理系統資料庫版本sqlite3版本;淺析資料庫的基礎用法及實際操作

大家好,我是道長王也。如果我不學程式碼, 就要回家繼承千億家產。我不想那樣,我不想讓就金錢腐蝕我的靈魂,我想通過自己的努力去過自己想要的人生。好了閒話不說。 今天我們來淺談資料庫(為什麼說淺談,因為往深了說勞資不會!) 引題 為什麼使用資料庫: 之前的學習中我們

學生管理系統跳轉頁面設計

新增頁面。 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4

學生管理系統頁面設計

頁面整體佈局,left,main,top三層佈局架構。 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html P

類封裝學生管理系統連線資料庫,增刪改查,拿去用,不謝。

# coding = utf-8 import sqlite3 class Student(object): def __init__(self, id, name, age, sex, phone): self.id = id self.name

python學生管理系統連線資料庫,很詳細,這個是用函式的增刪改查,拿去用,不謝。

# coding: utf-8 import sqlite3 # 匯入資料庫 def connect_sql(): connect = sqlite3.connect("test_sqlite.db") cursor = connect.cursor() cursor

C++課程設計學生管理系統

(一)新生基本資訊統計軟體 有新生來報到,要逐個錄入其資訊,如:學生姓名,性別,專業,出生日期,家庭地址,英語入學成績。要求設計連結串列類來實現,並統計學生人數。文字介面為: 1. 新增學生資訊 2. 刪除學生資訊 3. 匯入學生資訊(已經保存於的檔案資訊) 4. 學生資訊搜尋

史上最詳細c語言學生管理系統完整的原始碼

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<conio.h> struct student { char sno[12]; char n

C語言學生管理系統學生期末作業

** 純C語言學生管理系統(學生期末作業) ** 分為7大功能:增、刪、查、改、預覽、儲存、匯出 程式碼都加有註釋,利於不懂的,理解 新增功能 //新增學生 void input () { int i; int j,ge; DaoChu(); printf("

用反射完畢學生管理系統包含數據庫連接

幫我 循環輸出 .net into att reat 類別 學生管理系統 csdn 今天我最終將坑爹的萬能數據庫鏈接做好了第一步了,插入數據。 雖說非常easy。但還是應該總結一些問題。 一路的坎坷僅僅能如今表達了。 以下就是一些問題以及過程: 最重要的問題可能就是sq

java構建學生管理系統

class 管理系統 同時 進步 傳參 databases 什麽 界面 查看 用java搭建學生管理系統,重要還是對數據庫的操作,諸如增刪改查等。 1.基本的功能: 老師完成對學生信息的查看和修改,完成對班級的信息的概覽。 學生可以看自己的成績和對自己信息的修改。 學生和老

C++ 實現簡單命令行學生管理系統

什麽 cos wid 屏幕 cit 環境 iterator choice umeng C++ 實現簡單命令行學生管理系統 貼吧ID: 這把問題不大 編譯環境是macOS。system(“clear”) 在windows下請換成 system(“cls”) #include

學生管理系統有一定問題

sel let ets upd jdbc except cte int setname package lianjie; import java.sql.Connection;import java.sql.DriverManager;import java.sql.Res

C語言——單鏈表——學生管理系統

鞏固了一下單鏈表的知識點,並運用單鏈表寫了個簡單的學生管理系統 實現功能:增、刪、改、查 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #includ