导师制双选系统

 

综合应用算法训练

 

任务说明

设计一个用于软件工程系本科导师制双选的系统。

设计要求:

(1) 实现学生信息管理,支持信息更新;

(2) 实现教师信息管理,支持信息更新;

(3) 实现学生填写导师志愿的过程,并提供当前导师的选择情况;

(4) 实现基于规则的志愿调整过程;

(5) 实现导师的学生筛选过程;

(6) 实现各种信息的多类查询。

实验环境及实验准备

     C#编程语言

系统分析与设计

此部分包括软件程序的需求分析与软件设计部分,最好图文并茂。

(1)需求分析

         参照实验要求,实现调用数据库进行信息显示,导师学生互选,更新互选结果,管理员更改教师、学生信息,查询双选结果,调整志愿。

(2)软件设计

       数据库:教师表、学生表、管理员表

   登录:点选教师/学生/管理员登录,输入正确用户名(教师号、学号)和密码成功登录。

   教师:

    默认可带5个学生。

    邀请学生:列表显示未分配的学生信息,可选。若学生未达上限,即向选中的学生发出邀请,等待学生处理。学生将收到老师的基本信息和教学经历等内容。

    处理学生申请:若收到来自学生的申请,可选择同意或拒绝。

    刷新:更新显示信息

学生:

    只能有一位导师。

    修改个人简介:点击在文本框中输入要更改的内容,保存修改个人简介。

    申请导师:若无导师,可在选择申请导师,向导师发送申请,等待老师处理。导师将收到学生的基本信息和个人简介。

    处理导师邀请:若收到邀请,进入处理界面查看邀请信息,同意或拒绝邀请。

    刷新:刷新显示信息

管理员:

    进行教师表、学生表、双选表的增删改查。并将结果导出到.xls文件

说明本程序中用到的所有数据结构及数据类型的定义、主程序的流程以及各程序模块之间的调用关系图。

软件源代码

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 daoshizhi

{

    public partial class Form1 : Form

    {

        public static string welcome = "";

        public static string no = "";

        SqlConnection conn = new SqlConnection("server=.;database=tutorManagement;uid=sa;pwd=sa");

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            conn.Open();

            string username = textBox1.Text.Trim();

            string userpwd = textBox2.Text.Trim();

            if (username == "" || userpwd == "")

            {

                label2.Text = "用?户§名?或ò密ü码?不?能ü为a空?!";

            }

            else

            {

                string s1 = "select * from tutor where tno='" + username + "' and pwd='" + userpwd + "'";

                string s2 = "select * from student where sno='" + username + "' and pwd='" + userpwd + "'";

                string s3 = "select * from manager where mno='" + username + "' and pwd='" + userpwd + "'";

                if (radioButton1.Checked)

                {

                    SqlCommand s01 = new SqlCommand(s1, conn);

                    SqlDataReader t = s01.ExecuteReader();

                    if (t.Read())

                    {

                        conn.Close();

                        SqlDataAdapter s11 = new SqlDataAdapter(s1, conn);

                        DataSet ds = new DataSet();

                        conn.Open();

                        s11.Fill(ds, "tutor");

                        welcome=ds.Tables["tutor"].Rows[0]["tname"].ToString();

                        no= ds.Tables["tutor"].Rows[0]["tno"].ToString();

                        Form Form2 = new Form2();

                        Form2.Show();

                        this.Hide();

                    }

                    else label2.Text = "用?户§名?或ò密ü码?错洙?误ó!";

                }

                else if (radioButton2.Checked)

                {

                    SqlCommand s02 = new SqlCommand(s2, conn);

                    SqlDataReader t = s02.ExecuteReader();

                    if (t.Read())

                    {

                        conn.Close();

                        SqlDataAdapter s22 = new SqlDataAdapter(s2, conn);

                        DataSet ds = new DataSet();

                        conn.Open();

                        s22.Fill(ds, "student");

                        welcome = ds.Tables["student"].Rows[0]["name"].ToString();

                        no = ds.Tables["student"].Rows[0]["sno"].ToString();

                        Form Form3 = new Form3();

                        Form3.Show();

                        this.Hide();

                    }

                    else label2.Text = "用?户§名?或ò密ü码?错洙?误ó!";

                }

                else

                {

                    SqlCommand s03 = new SqlCommand(s3, conn);

                    SqlDataReader t = s03.ExecuteReader();

                    if (t.Read())

                    {

                        Form Form4 = new Form4();

                        Form4.Show();

                        this.Hide();

                    }

                    else label2.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.Windows.Forms;

using System.Data.SqlClient;

namespace daoshizhi

{

    public partial class Form2 : Form

    {

        public static string welcome =Form1.welcome;

        public static string no = Form1.no;

        SqlConnection conn = new SqlConnection("server=.;database=tutorManagement;uid=sa;pwd=sa");

        public static int k;

        public Form2()

        {

            InitializeComponent();

            label1.Text = "欢?迎?,?"+welcome+"老?师簗!?";

            /*显?示?我ò的?学§生Θ?/

            conn.Open();

            string s = "select * from student where tno='"+no+"'";

            SqlCommand a = new SqlCommand(s,conn);

            SqlDataReader dr = a.ExecuteReader();

            while (dr.Read())

            {

              listBox1.Items.Add(string.Format("{0}   {1}   {2}   {3}", dr[0], dr[1],dr[2],dr[3]));

            }

            dr.Close();

            /*显?示?待鋣分?配?学§生Θ?/

            string s2 = "select sno,name,sex,message from student where tno is NULL";

            SqlCommand b = new SqlCommand(s2,conn);

            SqlDataReader dr2 = b.ExecuteReader();

            while (dr2.Read())

            {

                listBox2.Items.Add(string.Format("{0}    {1}    {2}   {3}", dr2[0], dr2[1], dr2[2], dr2[3]));

                comboBox1.Items.Add(dr2[0]);

            }

            dr2.Close();

            conn.Close();

            /*显?示?学§生Θ?邀?请?*/

            conn.Open();

            string s3 = "select count(sno) from student where selectno='" + no + "'";

            SqlCommand c = new SqlCommand(s3, conn);

            SqlDataReader dr3 = c.ExecuteReader();

            if (dr3.Read())

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da1 = new SqlDataAdapter(s3, conn);

                DataSet ds = new DataSet();

                da1.Fill(ds, "学§生Θ?邀?请?人?数簓");

                string s4 = ds.Tables["学§生Θ?邀?请?人?数簓"].Rows[0][0].ToString();

                k = Int32.Parse(s4);

                linkLabel2.Text = "收?到?" + s4 + "个?学§生Θ?申Θ?请?";

            }

            dr3.Close();

            conn.Close();

        }

        private void panel1_Paint(object sender, PaintEventArgs e)

        {

        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            this.Close();

            Form1 f1 = new Form1();

            f1.Show();

        }

        private void Form2_Load(object sender, EventArgs e)

        {

        }

        private void label1_Click(object sender, EventArgs e)

        {

        }

        private void button1_Click(object sender, EventArgs e)

        {

            //邀?请?学§生Θ?

            if (comboBox1.SelectedIndex == -1) { MessageBox.Show("未′选?中D任?何?项?!?"); return; }

            /*计?算?已?选?和í正y在ú邀?请?的?学§生Θ?总哩?人?数簓,?不?能ü超?过y 5*/

            string m,n;

            int x=0,y=0;

            string s1 = "select count(*) from student where tno='" + no + "' group by tno";

            string s2 = "select count(*) from student where tnoselect='" + no + "' group by tnoselect";

            conn.Open();

            SqlCommand a = new SqlCommand(s1, conn);

            SqlDataReader dr1 = a.ExecuteReader();

            DataSet ds = new DataSet();

            if (dr1.Read())

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter(s1, conn);

                da.Fill(ds, "selected");

                m = ds.Tables["selected"].Rows[0][0].ToString();

                x = Int32.Parse(m);

            }

            conn.Close();

            conn.Open();

            SqlCommand b = new SqlCommand(s2, conn);

            SqlDataReader dr2 = b.ExecuteReader();

            if (dr2.Read())

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da1 = new SqlDataAdapter(s1, conn);

                da1.Fill(ds, "selecting");

                n = ds.Tables["selecting"].Rows[0][0].ToString();

                y = Int32.Parse(n);

            }

            conn.Close();

            if (x + y > 4)

            { MessageBox.Show("人?数簓将?超?过y最?大洙?限T制? 5!?"); return; }

            else

            {

                //将?选?择?结á果?添�?加ó到?学§生Θ?表括?

                y++;

                string s3 = "update student set tnoselect='" + no + "' where sno='" + comboBox1.SelectedItem.ToString() + "'";

                SqlCommand cmd = new SqlCommand(s3, conn);

                conn.Open();

                cmd.ExecuteNonQuery();

                conn.Close();

                MessageBox.Show("向ò" + comboBox1.SelectedItem + "发ぁ?出?邀?请? 您ú已?有瓺" + x.ToString() + "个?学§生Θ?,?正y在ú邀?请?" + y.ToString() + "个?学§生Θ?);

            }

        }

        private void button2_Click(object sender, EventArgs e)

        {

          

        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            Form5 f5 = new Form5();

            f5.Show();

            f5.Activate();

        }

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            //刷¢新?信?息¢

            listBox1.Items.Clear();

            listBox2.Items.Clear();

            //显?示?我ò的?学§生Θ?信?息¢

            conn.Open();

            string s = "select * from student where tno='" + no + "'";

            SqlCommand a = new SqlCommand(s, conn);

            SqlDataReader dr = a.ExecuteReader();

            while (dr.Read())

            {

                listBox1.Items.Add(string.Format("{0}   {1}   {2}   {3}", dr[0], dr[1], dr[2], dr[3]));

            }

            dr.Close();

            //显?示?待鋣分?配?学§生Θ?

            string s2 = "select sno,name,sex,message from student where tno is NULL";

            SqlCommand b = new SqlCommand(s2, conn);

            SqlDataReader dr2 = b.ExecuteReader();

            while (dr2.Read())

            {

                listBox2.Items.Add(string.Format("{0}    {1}    {2}   {3}", dr2[0], dr2[1], dr2[2], dr2[3]));

                comboBox1.Items.Add(dr2[0]);

            }

            dr2.Close();

            conn.Close();

            //显?示?学§生Θ?邀?请?

            string s3 = "select count(sno) from student where selectno='" + no + "'";

            conn.Open();

            SqlCommand c = new SqlCommand(s3, conn);

            SqlDataReader dr3 = c.ExecuteReader();

            if (dr3.Read())

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da1 = new SqlDataAdapter(s3, conn);

                DataSet ds = new DataSet();

                da1.Fill(ds, "学§生Θ?邀?请?人?数簓");

                string s4 = ds.Tables["学§生Θ?邀?请?人?数簓"].Rows[0][0].ToString();

                k = Int32.Parse(s4);

                linkLabel2.Text = "收?到?" + s4 + "个?学§生Θ?申Θ?请?";

            }

            dr3.Close();

            conn.Close();

        }

    }

}

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 daoshizhi

{

    public partial class Form3 : Form

    {

        public static int k=0;

        public static string welcome =Form1.welcome;

        public static string no = Form1.no;

        string sql1 = "select message from student where sno='" + no + "'";

        string sql2 = "select * from tutor where tno in (select tno from student where sno='" + no + "')";

        SqlConnection conn = new SqlConnection("server=.;database=tutorManagement;uid=sa;pwd=sa");

        public Form3()

        {

            InitializeComponent();

            label1.Text = "欢?迎?,?" + welcome+"!?";

            //显?示?个?人?简ò介é

            conn.Open();

            SqlDataAdapter da = new SqlDataAdapter(sql1, conn);

            DataSet ds = new DataSet();

            da.Fill(ds, "student");

            label6.Text = ds.Tables["student"].Rows[0]["message"].ToString();

            conn.Close();

            //显?示?导?师簗信?息¢

            conn.Open();

            SqlCommand c1 = new SqlCommand(sql2, conn);

            SqlDataReader dr = c1.ExecuteReader();

            if (dr.Read())

            {

                k = 1;//表括?示?已?有瓺导?师簗

                conn.Close();

                SqlDataAdapter dp = new SqlDataAdapter(sql2, conn);

                conn.Open();

                dp.Fill(ds, "tutor");

                label10.Text = ds.Tables["tutor"].Rows[0]["tname"].ToString();

                label11.Text = ds.Tables["tutor"].Rows[0]["tno"].ToString();

                label12.Text = ds.Tables["tutor"].Rows[0]["sex"].ToString();

                label7.Text = ds.Tables["tutor"].Rows[0]["message"].ToString();

                panel3.Show();

            }

            conn.Close();

            //显?示?导?师簗邀?请?人?数簓

            string s3 = "select count(tnoselect) from student where sno='" + no + "'";

            conn.Open();

            SqlCommand c = new SqlCommand(s3, conn);

            SqlDataReader dr3 = c.ExecuteReader();

            if (dr3.Read())

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da1 = new SqlDataAdapter(s3, conn);

                da1.Fill(ds, "导?师簗邀?请?人?数簓");

                string s4 = ds.Tables["导?师簗邀?请?人?数簓"].Rows[0][0].ToString();

                linkLabel2.Text = "收?到?" + s4 + "个?导?师簗邀?请?";

            }

            dr3.Close();

            conn.Close();

        }

        private void button1_Click(object sender, EventArgs e)

        {

        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            this.Close();

            Form1 f1 = new Form1();

            f1.Show();

        }

        private void button2_Click(object sender, EventArgs e)

        {

            //显?示?个?人?简ò介é

            panel1.Show();

            panel2.Visible = false;

        }

        private void buttonSave_Click(object sender, EventArgs e)

        {

            //修T改?数簓据Y库a个?人?简ò介é

                string s1 = "update student set message='" + textBox1.Text + "' where sno='" + no + "'";

                conn.Open();

                SqlCommand cmd = new SqlCommand(s1, conn);

                cmd.ExecuteNonQuery();

                conn.Close();

            MessageBox.Show("修T改?成é功|");

            textBox1.Text = "";

            panel1.Visible = false;

            //更ü新?显?示?个?人?简ò介é信?息¢

            conn.Open();

            SqlDataAdapter da = new SqlDataAdapter(sql1, conn);

            DataSet ds = new DataSet();

            da.Fill(ds, "student");

            label6.Text = ds.Tables["student"].Rows[0]["message"].ToString();

            conn.Close();

        }

        private void button6_Click(object sender, EventArgs e)

        {

            //取?消?简ò介é设Θ?置?

            panel1.Visible = false;

            textBox1.Text = "";

        }

        private void button3_Click(object sender, EventArgs e)

        {

            listBox1.Items.Clear();

            comboBox1.Items.Clear();

            if (k == 0)

            {

                panel1.Visible = false;

                panel2.Visible = true;

                //显?示?导?师簗选?择?框ò

                string s2 = "select tno,tname,sex,message from tutor where tno in(select student.tno from student join tutor on student.tno=tutor.tno group by student.tno having count(sno)<5) or tno not in(select student.tno from student join tutor on student.tno=tutor.tno) ";

                conn.Open();

                SqlCommand a = new SqlCommand(s2, conn);

                SqlDataReader dr = a.ExecuteReader();

                while (dr.Read())

                {

                    listBox1.Items.Add(string.Format("{0}    {1}    {2}    {3}", dr[0], dr[1], dr[2], dr[3]));

                    comboBox1.Items.Add(dr[0]);

                }

                dr.Close();

                conn.Close();

            }

            else

                MessageBox.Show("您ú已?经-有瓺导?师簗了?!?");

        }

        private void button4_Click(object sender, EventArgs e)

        {

            //选?择?导?师簗

            string selectno = comboBox1.SelectedItem.ToString();//获?取?选?择?的?教ì师簗号?

            /*教ì师簗所ù带?学§生Θ?是?否?满ú员±*/

            string s0 = "select count(*) from student where tno='" + selectno + "' group by tno";

            conn.Open();

            SqlCommand a= new SqlCommand(s0,conn);

            SqlDataReader dr=a.ExecuteReader();

            DataSet ds = new DataSet();

            int x=0;

            if (dr.Read() )

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter(s0, conn);

                da.Fill(ds, "selected");

                string m = ds.Tables["selected"].Rows[0][0].ToString();

                x = Int32.Parse(m);

                conn.Close();

            }

            dr.Close();

            conn.Close();

            if (x > 5)

                MessageBox.Show("该?教ì师簗所ù带?学§生Θ?已?经-满ú员±,?请?重?新?选?择?教ì师簗!?");

            else

            {

                /*选?择?结á果?添�?加ó到?表括?/

                string s1 = "update student set selectno='"+selectno+"' where sno='"+ no + "'";

                conn.Open();

                SqlCommand cmd = new SqlCommand(s1, conn);

                cmd.ExecuteNonQuery();

                conn.Close();

                /*获?得?教ì师簗姓?名?*/

                string s2 = "select tname from tutor where tno='" + selectno + "'";

                conn.Open();

                SqlDataAdapter da1 = new SqlDataAdapter(s2, conn);

                da1.Fill(ds, "选?择?教ì师簗");

                string selectname = ds.Tables["选?择?教ì师簗"].Rows[0]["tname"].ToString();

                conn.Close();

                MessageBox.Show("向ò " + selectname + " 老?师簗发ぁ?出?了?申Θ?请?");

                panel2.Visible = false;

                listBox1.Items.Clear();

                comboBox1.Items.Clear();

            }

        }

        private void button5_Click(object sender, EventArgs e)

        {

            //取?消?选?择?导?师簗

            panel2.Visible = false;

            listBox1.Items.Clear();

            comboBox1.Items.Clear();

        }

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            //刷¢新?

            conn.Open();

            SqlCommand c1 = new SqlCommand(sql2, conn);

            SqlDataReader dr = c1.ExecuteReader();

            if (dr.Read())

            {

                k = 1;

                conn.Close();

                SqlDataAdapter dp = new SqlDataAdapter(sql2, conn);

                DataSet ds = new DataSet();

                conn.Open();

                dp.Fill(ds, "tutor");

                label10.Text = ds.Tables["tutor"].Rows[0]["tname"].ToString();

                label11.Text = ds.Tables["tutor"].Rows[0]["tno"].ToString();

                label12.Text = ds.Tables["tutor"].Rows[0]["sex"].ToString();

                label7.Text = ds.Tables["tutor"].Rows[0]["message"].ToString();

                panel3.Show();

            }

            conn.Close();

            //显?示?导?师簗邀?请?人?数簓

            string s3 = "select count(tnoselect) from student where sno='" + no + "'";

            conn.Open();

            SqlCommand c = new SqlCommand(s3, conn);

            SqlDataReader dr3 = c.ExecuteReader();

            if (dr3.Read())

            {

                conn.Close();

                conn.Open();

                SqlDataAdapter da1 = new SqlDataAdapter(s3, conn);

                DataSet ds = new DataSet();

                da1.Fill(ds, "导?师簗邀?请?人?数簓");

                string s4 = ds.Tables["导?师簗邀?请?人?数簓"].Rows[0][0].ToString();

                linkLabel2.Text = "收?到?" + s4 + "个?导?师簗邀?请?";

            }

            dr3.Close();

            conn.Close();

        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            Form6 f6 = new Form6();

            f6.Show();

        }

    }

}

Form4 管理员界面

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;

using Excel = Microsoft.Office.Interop.Excel;

namespace daoshizhi

{

    public partial class Form4 : Form

    {

        SqlConnection conn = new SqlConnection("server=.;database=tutorManagement;uid=sa;pwd=sa");

        string s1 = "select student.tno as 教ì师簗号?,tname as 导?师簗姓?名?,sno as 学§号?,name as 学§生Θ?姓?名? from student join tutor on student.tno=tutor.tno order by student.tno,sno";

        string s2 = "select tno as 教ì师簗号?,tname as 姓?名?,sex as 性?别纄,message as 简ò介é from tutor";

        string s3 = "select sno as 学§号?,name as 姓?名?,sex as 性?别纄,message as 自?我ò简ò介é from student";

        string s4 = "select count(sno) from student";

        string s5 = "select count(sno) from student where tno is not null";

        public SqlDataAdapter adap = new SqlDataAdapter();

        public DataSet ds = new DataSet();

        public Form4()

        {

            InitializeComponent();

        }

        private void Form4_Load(object sender, EventArgs e)

        {

        }

        private void button1_Click(object sender, EventArgs e)

        {

            //显?示?双?选?表括?

            dataGridView1.DataSource = null;

            adap.SelectCommand = new SqlCommand(s1, conn);

            adap.Fill(ds, "双?选?表括?);

            dataGridView1.DataSource = ds.Tables["双?选?表括?];

            conn.Open();

            SqlDataAdapter da = new SqlDataAdapter(s4,conn);

            DataSet ds2 = new DataSet();

            da.Fill(ds2, "学§生Θ?人?数簓");

            string x0 = ds2.Tables["学§生Θ?人?数簓"].Rows[0][0].ToString();

            conn.Close();

            conn.Open();

            SqlDataAdapter da1 = new SqlDataAdapter(s5, conn);

            DataSet ds3 = new DataSet();

            da1.Fill(ds3, "已?完�?成é双?选?学§生Θ?人?数簓");

            string y0 = ds3.Tables["已?完�?成é双?选?学§生Θ?人?数簓"].Rows[0][0].ToString();

            conn.Close();

            label2.Text = "已?有瓺" + y0 + "/" +x0+ "学§生Θ?完�?成é双?选?";

            ds.Tables.Clear();

            ds2.Tables.Clear();

            ds3.Tables.Clear();

        }

        private void button2_Click(object sender, EventArgs e)

        {

            //显?示?教ì师簗表括?

            dataGridView1.DataSource = null;

            adap.SelectCommand = new SqlCommand(s2, conn);

            adap.Fill(ds, "教ì师簗表括?);

            dataGridView1.DataSource = ds.Tables["教ì师簗表括?];

            ds.Tables.Clear();

           /* button4.Show();

            button5.Show();

            button6.Show();

            button10.Hide();

            button9.Hide();

            button8.Hide();*/

        }

        private void button3_Click(object sender, EventArgs e)

        {

            //显?示?学§生Θ?表括?

            dataGridView1.DataSource = null;

            adap.SelectCommand = new SqlCommand(s3, conn);

            adap.Fill(ds, "学§生Θ?表括?);

            dataGridView1.DataSource = ds.Tables["学§生Θ?表括?];

            ds.Tables.Clear();

           /* button4.Hide();

            button5.Hide();

            button6.Hide();

            button10.Show();

            button9.Show();

            button8.Show();*/

        }

        private void button4_Click(object sender, EventArgs e)

        {

               

        }

        private void button7_Click(object sender, EventArgs e)

        {

            ExportDataGridview(dataGridView1,true);

        }

        public bool ExportDataGridview(DataGridView gridView, bool isShowExcle)

        {

            if (gridView.Rows.Count == 0)

            {

                return false;

            }

            //创洹?建¨Excel对?象ó

            Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();

            excel.Application.Workbooks.Add(true);

            //生Θ?成é字?段?名?称?

            for (int i = 0; i < gridView.ColumnCount; i++)

            {

                excel.Cells[1, i + 1] = gridView.Columns[i].HeaderText;

            }

            //填?充?数簓据Y

            for (int i = 0; i < gridView.RowCount - 1; i++)   //循-环·行D

            {

                for (int j = 0; j < gridView.ColumnCount; j++) //循-环·列�

                {

                    if (gridView[j, i].ValueType == typeof(string))

                    {

                        excel.Cells[i + 2, j + 1] = "'" + gridView.Rows[i].Cells[j].Value.ToString();

                    }

                    else

                    {

                        excel.Cells[i + 2, j + 1] = gridView.Rows[i].Cells[j].Value.ToString();

                    }

                }

            }

            //设Θ?置?禁?止1弹獭?出?保馈?存?和í覆2盖?询ˉ问ê提�?示?框ò 

            excel.Visible = false;

            excel.DisplayAlerts = false;

            excel.AlertBeforeOverwriting = false;

            //保馈?存?临ⅷ?时骸?工¤作痢?簿?

            //excel.Application.Workbooks.Add(true).Save();

            //保馈?存?文?件t

            excel.Save("D:" + "\234.xls");

            excel.Quit();

            return true;

        }

    }

}

Form5 处理学生申请

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 daoshizhi

{

    public partial class Form5 : Form

    {

        SqlConnection conn = new SqlConnection("server=.;database=tutorManagement;uid=sa;pwd=sa");

        public static string no = Form2.no;

        public Form5()

        {

           

            InitializeComponent();

            conn.Open();

            string s = "select sno,name,sex,message from student where selectno='" + no + "'";

            SqlCommand a = new SqlCommand(s, conn);

            SqlDataReader dr = a.ExecuteReader();

            while (dr.Read())

            {

                listBox1.Items.Add(string.Format("{0}   {1}   {2}   {3}", dr[0], dr[1], dr[2], dr[3]));

                comboBox1.Items.Add(dr[0]);

            }

            conn.Close();

        }

        private void button1_Click(object sender, EventArgs e)

        {//接ó受酣?邀?请?

            if (comboBox1.SelectedIndex == -1) { MessageBox.Show("未′选?中D任?何?项?!?"); return; }

            string s1 = comboBox1.SelectedItem.ToString();

            string s2 = "update student set tno='" + no + "' where sno='" + s1 + "'";

            string s3 = "update student set tno=null where sno='" + s1 + "'";

            conn.Open();

            SqlCommand cmd = new SqlCommand(s2, conn);

            cmd.ExecuteNonQuery();

            conn.Close();

            comboBox1.SelectedIndex = 0;

            conn.Open();

            SqlCommand cmd2 = new SqlCommand(s3, conn);

            cmd2.ExecuteNonQuery();

            conn.Close();

            MessageBox.Show("添�?加ó学§生Θ?+s1);

            comboBox1.Items.Remove(comboBox1.SelectedItem);

        }

        private void button2_Click(object sender, EventArgs e)

        {//拒ü绝?邀?请?

            if (comboBox1.SelectedIndex == -1) { MessageBox.Show("未′选?中D任?何?项?!?"); return; }

            string s1 = comboBox1.SelectedItem.ToString();

            comboBox1.Items.Remove(comboBox1.SelectedItem);

            string s2 = "update student set selectno=null where sno='" + s1 + "'";

            conn.Open();

            SqlCommand cmd = new SqlCommand(s2, conn);

            cmd.ExecuteNonQuery();

            conn.Close();

            MessageBox.Show("拒ü绝?了?来ぁ?自?"+s1+"的?申Θ?请?");

        }

    }

}

Form6 处理导师邀请

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 daoshizhi

{

    public partial class Form6 : Form

    {

        SqlConnection conn = new SqlConnection("server=.;database=tutorManagement;uid=sa;pwd=sa");

        public static string no = Form3.no;

        public Form6()

        {

            InitializeComponent();

            conn.Open();

            string s = "select tno,tname,sex,message from tutor where tno=(select tnoselect from student where sno='" + no + "')";

            SqlCommand a = new SqlCommand(s, conn);

            SqlDataReader dr = a.ExecuteReader();

            while (dr.Read())

            {

                listBox1.Items.Add(string.Format("{0}   {1}   {2}   {3}", dr[0], dr[1], dr[2], dr[3]));

                comboBox1.Items.Add(dr[0]);

            }

            conn.Close();

        }

        private void button1_Click(object sender, EventArgs e)

        {//接ó受酣?邀?请?

            if (comboBox1.SelectedIndex == -1) { MessageBox.Show("未′选?中D任?何?项?!?"); return; }

            string s1 = comboBox1.SelectedItem.ToString();

            string s2 = "update student set tno='" + s1 + "' where sno='" + no + "'";

            string s3 = "update student set tnoselect=null where sno='" + no + "'";

            conn.Open();

            SqlCommand cmd = new SqlCommand(s2, conn);

            cmd.ExecuteNonQuery();

            conn.Close();

            comboBox1.Items.Remove(comboBox1.SelectedItem);

            conn.Open();

            SqlCommand cmd2 = new SqlCommand(s3, conn);

            cmd2.ExecuteNonQuery();

            conn.Close();

            MessageBox.Show("添�?加ó导?师簗 " + s1);

            Form3.k = 1;

        }

        private void button2_Click(object sender, EventArgs e)

        {

            //拒ü绝?邀?请?

            if (comboBox1.SelectedIndex == -1) { MessageBox.Show("未′选?中D任?何?项?!?"); return; }

            string s1 = comboBox1.SelectedItem.ToString();

            comboBox1.Items.Remove(comboBox1.SelectedItem);

            string s2 = "update student set tnoselect=null where sno='" + no + "'";

            conn.Open();

            SqlCommand cmd = new SqlCommand(s2, conn);

            cmd.ExecuteNonQuery();

            conn.Close();

            MessageBox.Show("拒ü绝?了?来ぁ?自? " + s1 + " 的?邀?请?");

        }

    }

}

软件测试说明

登录界面

无导师时

修改个人简介

 

申请导师

教师登录

邀请学生

处理学生申请

管理员

此部分包括软件的测试数据与测试截图及说明,最好使用三中的测试用例。

软件使用说明

登录:点选教师/学生/管理员登录,输入正确用户名(教师号、学号)和密码成功登录。

教师:

    默认可带5个学生。界面显示“我的学生”和全部目前无导师的“待分配学生”。

    邀请学生:点选下拉框中的学号,点击“邀请”,若学生未达上限,即向选中的学生发出邀请,等待学生处理。学生将收到老师的基本信息和教学经历等内容。

    处理学生申请:若收到来自学生的申请,点击进入处理界面,可同意或拒绝。

    刷新:点击刷新可更新显示信息

学生:

    只能有一位导师。界面显示“个人简介”和导师信息。

    修改个人简介:点击在文本框中输入要更改的内容,保存可修改个人简介。

    申请导师:若无导师信息,点击“申请导师”按钮可在下拉列表中选择导师,点击“申请”,向导师发送申请,等待老师处理。导师将收到学生的基本信息和个人简介。

    处理导师邀请:若收到邀请,点击可进入处理界面查看邀请信息,点选下拉框,点选按钮同意或拒绝邀请。

    刷新:刷新显示信息

管理员:

    根据按钮提示进行教师表、学生表、双选表的增删改查。

    

原文地址:https://www.cnblogs.com/candy-yyn/p/4099160.html