学生成绩管理系统

Posted chenfeifen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学生成绩管理系统相关的知识,希望对你有一定的参考价值。

一、登录界面程序

  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Text;
  7 using System.Windows.Forms;
  8 using System.Data.SqlClient;
  9 
 10 namespace StudentSystem
 11 {
 12     public partial class Form_denglu : Form
 13     {
 14         public Form_denglu()
 15         {
 16             InitializeComponent();
 17             init();
 18         }
 19         public void init()
 20         {
 21             textBox_zhanghao.Text = "请输入邮箱或手机号";
 22             textBox_zhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
 23             textBox_mima.Text = "请输入密码";
 24             textBox_mima.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
 25         }
 26         private void button_queding_Click(object sender, EventArgs e)
 27         {
 28             //创建数据库连接类的对象
 29             SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
 30             //将连接打开
 31             con.Open();
 32             //执行con对象的函数,返回一个SqlCommand类型的对象
 33             SqlCommand cmd = con.CreateCommand();
 34             //把输入的数据拼接成sql语句,并交给cmd对象
 35             cmd.CommandText = "select *from users where username=‘" + textBox_zhanghao.Text + "‘and password=‘" + textBox_mima.Text + "";
 36 
 37             //用cmd的函数执行语句,返回SqlDataReader对象dr,dr就是返回的结果集(也就是数据库中查询到的表数据)
 38             SqlDataReader dr = cmd.ExecuteReader();
 39             if (!String.IsNullOrEmpty(textBox_zhanghao.Text) && !String.IsNullOrEmpty(textBox_mima.Text))
 40             {
 41                 //用dr的read函数,每执行一次,返回一个包含下一行数据的集合dr,在执行read函数之前,dr并不是集合
 42                 if (dr.Read())
 43                 {
 44                     DialogResult dengluresult = MessageBox.Show("登录成功!!!");
 45                     if (dengluresult == DialogResult.OK)
 46                     {
 47                         con.Close();
 48                         Form_login form_StudentMassage = new Form_login();
 49                         this.Visible = false;
 50                         form_StudentMassage.ShowDialog();
 51                     }
 52                 }
 53                 else
 54                 {
 55                     MessageBox.Show("账号或者密码错误!!!");
 56                     textBox_mima.Text = "";
 57                 }
 58                 //用完后关闭连接,以免影响其他程序访问
 59                 con.Close();
 60             }
 61             else
 62             {
 63                 MessageBox.Show("账号或者密码不能为空!!!");
 64                 textBox_mima.Text = "";
 65             }
 66         }
 67 
 68         private void textBox_zhanghao_MouseClick(object sender, MouseEventArgs e)
 69         {
 70             if(textBox_zhanghao.Text == "请输入邮箱或手机号")
 71             {
 72                 textBox_zhanghao.Text = "";
 73                 textBox_zhanghao.ForeColor = System.Color.Black;
 74             }
 75             if (textBox_mima.Text=="")
 76             {
 77                 textBox_mima.Text = "请输入密码";
 78                 textBox_mima.ForeColor = System.Drawing.SystemColors.WindowFrame;
 79                 textBox_mima.PasswordChar = ;
 80             }
 81         }
 82 
 83         private void textBox_mima_MouseClick(object sender, MouseEventArgs e)
 84         {
 85             if (textBox_mima.Text == "请输入密码")
 86             {
 87                  textBox_mima.Text = "";
 88                  textBox_mima.ForeColor = System.Color.Black;
 89                  textBox_mima.PasswordChar = *;
 90             }
 91            
 92             if (textBox_zhanghao.Text == "")
 93             {
 94                 textBox_zhanghao.Text = "请输入邮箱或手机号";
 95                 textBox_zhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
 96             }
 97         }
 98 
 99         private void checkBox_shifoukejian_CheckedChanged(object sender, EventArgs e)
100         {
101             if (checkBox_shifoukejian.Checked == true|| textBox_mima.Text == "请输入密码")
102             {
103                 textBox_mima.PasswordChar = ;
104             }
105             else
106             {
107                 textBox_mima.PasswordChar = *;
108             }
109         }
110 
111         private void linkLabel_xiugaimima_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
112         {
113             Form_xiugaimima form_xiugaimima = new Form_xiugaimima();
114             this.Visible = false;
115             form_xiugaimima.ShowDialog();
116         }
117 
118         private void linkLabel_zhuxiao_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
119         {
120             Form_zhuxiao form_zhuxiao = new Form_zhuxiao();
121             this.Visible = false;
122             form_zhuxiao.ShowDialog();
123         }
124 
125         private void button_zhuce_Click(object sender, EventArgs e)
126         {
127             Form_registration registration = new Form_registration();
128             this.Visible = false;
129             registration.ShowDialog();
130         }
131     }
132 }

技术分享图片

 

二、注册界面程序

  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Text;
  7 using System.Windows.Forms;
  8 using System.Data.SqlClient;
  9 using System.Text.RegularExpressions;
 10 
 11 namespace StudentSystem
 12 {
 13     public partial class Form_registration : Form
 14     {
 15         public Form_registration()
 16         {
 17             InitializeComponent();
 18             init_zhuce();
 19         }
 20         public void init_zhuce()
 21         {
 22             textBox_zhucezhanghao.Text = "请输入邮箱或手机号";
 23             textBox_zhucezhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
 24             textBox_zhucemima.Text = "请输入密码";
 25             textBox_zhucemima.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
 26         }
 27         //设置判断是否为数字的方法
 28         public bool boolNumber(string temp)
 29         {
 30             for(int i = 0; i < temp.Length; i++)
 31             {
 32                 byte tempByte = Convert.ToByte(temp[i]);
 33                 if ((tempByte < 48) || (tempByte > 57))
 34                 {
 35                     return false;
 36                 }
 37             }
 38             return true;
 39         }
 40         private void button_zhuce_Click(object sender, EventArgs e)
 41         {
 42             //正确的邮箱格式
 43             string email = @"1[3578][01379]d{8}$";
 44             Regex regexEmail = new Regex(email);
 45             //电信手机号码正则
 46             string dianxin = @"1[3578][01379]d{8}$";
 47             Regex regexDX = new Regex(dianxin);
 48             //联通手机号码正则
 49             string liantong = @"1[34578][01256]d{8}";
 50             Regex regexLT = new Regex(liantong);
 51             //移动手机号码正则
 52             string yidong = @"(1[012345678]d{9}|1[345678][012356789]d{8})$";
 53             Regex regexYD = new Regex(yidong);
 54 
 55             //创建数据库连接类的对象
 56             SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
 57             //将连接打开
 58             con.Open();
 59             //执行con对象的函数,返回一个SqlCommand类型的对象
 60             SqlCommand cmd = con.CreateCommand();
 61 
 62             cmd.CommandText = "select*from users where username=‘" + textBox_zhucezhanghao.Text + "";
 63             SqlDataReader dr = cmd.ExecuteReader();
 64 
 65             if (!String.IsNullOrEmpty(textBox_zhucezhanghao.Text) && !String.IsNullOrEmpty(textBox_zhucemima.Text))
 66             {
 67                 if (boolNumber(textBox_zhucezhanghao.Text.ToString()))
 68                 {
 69                     if(regexDX.IsMatch(textBox_zhucezhanghao.Text.ToString()) || regexLT.IsMatch(textBox_zhucezhanghao.Text.ToString()) || regexYD.IsMatch(textBox_zhucezhanghao.Text.ToString()))
 70                     {
 71                         if (dr.Read())
 72                         {
 73                             MessageBox.Show("该账号已经存在,请重新注册!");
 74                             textBox_zhucezhanghao.Text = "";
 75                             textBox_zhucemima.Text = "";
 76                         }
 77                         else
 78                         {
 79                             con.Close();
 80                             con.Open();
 81                             //拼写语句
 82                             cmd.CommandText = "insert into users values(‘" + textBox_zhucezhanghao.Text + "‘,‘" + textBox_zhucemima.Text + "‘)";
 83                             //增删改用ExecuteNonQuery,会返回一个整型数字
 84                             int count = cmd.ExecuteNonQuery();
 85                             if (count > 0)
 86                             {
 87                                 DialogResult result = MessageBox.Show("注册成功!");
 88                                 if (result == DialogResult.OK)
 89                                 {
 90                                     con.Close();
 91                                     Form_denglu login = new Form_denglu();
 92                                     this.Visible = false;
 93                                     login.ShowDialog();
 94                                 }
 95                             }
 96                             else
 97                             {
 98                                 MessageBox.Show("注册失败!");
 99                             }
100                         }
101                     }
102                     else
103                     {
104                         MessageBox.Show("手机号码不合法!");
105                         textBox_zhucezhanghao.Text = "";
106                         textBox_zhucemima.Text = "";
107                     }
108                 }
109                 else
110                 {
111                     if (!regexEmail.IsMatch(textBox_zhucezhanghao.Text.ToString()))
112                     {
113                         MessageBox.Show("邮箱格式不正确!");
114                         textBox_zhucezhanghao.Text = "";
115                         textBox_zhucemima.Text = "";
116                     }
117                     else
118                     {
119                         if (dr.Read())
120                         {
121                             MessageBox.Show("该账号已经存在,请重新注册!");
122                             textBox_zhucezhanghao.Text = "";
123                             textBox_zhucemima.Text = "";
124                         }
125                         else
126                         {
127                             con.Close();
128                             con.Open();
129                             //拼写语句
130                             cmd.CommandText = "insert into users values(‘" + textBox_zhucezhanghao.Text + "‘,‘" + textBox_zhucemima.Text + "‘)";
131                             //增删改用ExecuteNonQuery,会返回一个整型数字
132                             int count = cmd.ExecuteNonQuery();
133                             if (count > 0)
134                             {
135                                 DialogResult result = MessageBox.Show("注册成功!");
136                                 if (result == DialogResult.OK)
137                                 {
138                                     con.Close();
139                                     Form_denglu login = new Form_denglu();
140                                     this.Visible = false;
141                                     login.ShowDialog();
142                                 }
143                             }
144                             else
145                             {
146                                 MessageBox.Show("注册失败!");
147                             }
148                         }
149 
150                     }
151                 }
152             }
153             else
154             {
155                 MessageBox.Show("账号或者密码不能为空!!!");
156                 textBox_zhucemima.Text = "";
157             }
158         }
159 
160         private void textBox_zhucezhanghao_MouseClick_1(object sender, MouseEventArgs e)
161         {
162             if (textBox_zhucezhanghao.Text == "请输入邮箱或手机号")
163             {
164                 textBox_zhucezhanghao.Text = "";
165                 textBox_zhucezhanghao.ForeColor = System.Color.Black;
166             }
167             if (textBox_zhucemima.Text == "")
168             {
169                 textBox_zhucemima.Text = "请输入密码";
170                 textBox_zhucemima.ForeColor = System.Drawing.SystemColors.WindowFrame;
171                 textBox_zhucemima.PasswordChar = ;
172             }
173         }
174 
175         private void textBox_zhucemima_MouseClick_1(object sender, MouseEventArgs e)
176         {
177             if (textBox_zhucemima.Text == "请输入密码")
178             {
179                 textBox_zhucemima.Text = "";
180                 textBox_zhucemima.ForeColor = System.Color.Black;
181                 textBox_zhucemima.PasswordChar = *;
182             }
183 
184             if (textBox_zhucezhanghao.Text == "")
185             {
186                 textBox_zhucezhanghao.Text = "请输入邮箱或手机号";
187                 textBox_zhucezhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
188             }
189         }
190 
191         private void checkBox_zhuce_CheckedChanged(object sender, EventArgs e)
192         {
193             if (checkBox_zhuce.Checked == true || textBox_zhucemima.Text == "请输入密码")
194             {
195                 textBox_zhucemima.PasswordChar = ;
196             }
197             else
198             {
199                 textBox_zhucemima.PasswordChar = *;
200             }
201         }
202 
203         private void button_fanhui_Click(object sender, EventArgs e)
204         {
205             Form_denglu login = new Form_denglu();
206             this.Visible = false;
207             login.ShowDialog();
208         }
209     }
210 }

技术分享图片

三、修改密码界面程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;//连接sql server
namespace StudentSystem
{
    public partial class Form_xiugaimima : Form
    {
        public Form_xiugaimima()
        {
            InitializeComponent();
            init_xiugai();
        }
        public void init_xiugai()
        {
            textBox_xiugaizhanghao.Text = "请输入账号";
            textBox_xiugaizhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; 
            textBox_yuanmima.Text = "请输入原密码";
            textBox_yuanmima.ForeColor = System.Drawing.SystemColors.WindowFrame;
            textBox_xinmima.Text = "请输入新密码";
            textBox_xinmima.ForeColor = System.Drawing.SystemColors.WindowFrame;
        }
        private void button_xiugaimima_Click(object sender, EventArgs e)
        {

            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            //将连接打开
            con.Open();
            //执行con对象的函数,返回一个SqlCommand类型的对象
            SqlCommand cmd = con.CreateCommand();
            //把输入的数据拼接成sql语句,并交给cmd对象
            cmd.CommandText = "select*from users where username=‘" + textBox_xiugaizhanghao.Text + "‘and password=‘" + textBox_yuanmima.Text + "";

            //用cmd的函数执行语句,返回SqlDataReader对象dr,dr就是返回的结果集(也就是数据库中查询到的表数据)
            SqlDataReader dr = cmd.ExecuteReader();
            if (!String.IsNullOrEmpty(textBox_xiugaizhanghao.Text) && !String.IsNullOrEmpty(textBox_yuanmima.Text)&& !String.IsNullOrEmpty(textBox_xinmima.Text))
            {
                //用dr的read函数,每执行一次,返回一个包含下一行数据的集合dr,在执行read函数之前,dr并不是集合
                if (dr.Read())
                {
                    //用完后关闭连接,以免影响其他程序访问
                    con.Close();
                    //将连接打开
                    con.Open();

                    cmd.CommandText = "update users set password=‘" + textBox_xinmima.Text + "‘where username=‘" + textBox_xiugaizhanghao.Text+"";
                    //增删改用ExecuteNonQuery,会返回一个整型数字
                    int count = cmd.ExecuteNonQuery();
                    if (count > 0)
                    {
                        DialogResult xiugairesult = MessageBox.Show("修改密码成功!");
                        if (xiugairesult == DialogResult.OK)
                        {
                            Form_denglu form_denglu = new Form_denglu();
                            this.Visible = false;
                            form_denglu.ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("修改密码失败!");
                    }
                    //用完后关闭连接,以免影响其他程序访问
                    con.Close();
                }
                else
                {
                    MessageBox.Show("账号或者密码错误!!!");
                }
            }
            else
            {
                MessageBox.Show("账号或者密码不能为空!!!");
            }
        }

        private void textBox_xiugaizhanghao_MouseClick(object sender, MouseEventArgs e)
        {
            if (textBox_xiugaizhanghao.Text == "请输入账号")
            {
                textBox_xiugaizhanghao.Text = "";
                textBox_xiugaizhanghao.ForeColor = System.Color.Black;
            }
            if (textBox_yuanmima.Text == "")
            {
                textBox_yuanmima.Text = "请输入原密码";
                textBox_yuanmima.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBox_yuanmima.PasswordChar = ;
            }
            if (textBox_xinmima.Text == "")
            {
                textBox_xinmima.Text = "请输入新密码";
                textBox_xinmima.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBox_xinmima.PasswordChar = ;
            }
        }

        private void textBox_yuanmima_MouseClick(object sender, MouseEventArgs e)
        {
            if (textBox_yuanmima.Text == "请输入原密码")
            {
                textBox_yuanmima.Text = "";
                textBox_yuanmima.ForeColor = System.Color.Black;
                textBox_yuanmima.PasswordChar = *;
            }

            if (textBox_xiugaizhanghao.Text == "")
            {
                textBox_xiugaizhanghao.Text = "请输入账号";
                textBox_xiugaizhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
            }

            if (textBox_xinmima.Text == "")
            {
                textBox_xinmima.Text = "请输入新密码";
                textBox_xinmima.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBox_xinmima.PasswordChar = ;
            }
        }

        private void textBox_xinmima_MouseClick(object sender, MouseEventArgs e)
        {
            if (textBox_xinmima.Text == "请输入新密码")
            {
                textBox_xinmima.Text = "";
                textBox_xinmima.ForeColor = System.Color.Black;
                textBox_xinmima.PasswordChar = *;
            }

            if (textBox_xiugaizhanghao.Text == "")
            {
                textBox_xiugaizhanghao.Text = "请输入账号";
                textBox_xiugaizhanghao.ForeColor = System.Drawing.SystemColors.WindowFrame; ;
            }

            if (textBox_yuanmima.Text == "")
            {
                textBox_yuanmima.Text = "请输入原密码";
                textBox_yuanmima.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBox_yuanmima.PasswordChar = ;
            }
        }

        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_denglu login = new Form_denglu();
            this.Visible = false;
            login.ShowDialog();
        }
    }
}

技术分享图片

四、注销界面程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_zhuxiao : Form
    {
        public Form_zhuxiao()
        {
            InitializeComponent();
        }

        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_denglu form_denglu = new Form_denglu();
            this.Visible = false;
            form_denglu.ShowDialog();
        }

        private void button_quedingzhuxiao_Click(object sender, EventArgs e)
        {
            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            //将连接打开
            con.Open();

            //执行con对象的函数,返回一个SqlCommand类型的对象
            SqlCommand cmd = con.CreateCommand();
            //把输入的数据拼接成sql语句,并交给cmd对象
            cmd.CommandText = "select*from users where username=‘" + textBox_zhuxiaozhanghao.Text + "‘and password=‘" + textBox_zhuxiaomima.Text + "";
            //用cmd的函数执行语句,返回SqlDataReader对象dr,dr就是返回的结果集(也就是数据库中查询到的表数据)
            SqlDataReader dr = cmd.ExecuteReader();
            if (!String.IsNullOrEmpty(textBox_zhuxiaozhanghao.Text) && !String.IsNullOrEmpty(textBox_zhuxiaomima.Text))
            {
                //用dr的read函数,每执行一次,返回一个包含下一行数据的集合dr,在执行read函数之前,dr并不是集合
                if (dr.Read())
                {
                    con.Close();
                    con.Open();
                    //拼写语句
                    cmd.CommandText = "delete from users where username=‘" + textBox_zhuxiaozhanghao.Text + "‘and password=‘" + textBox_zhuxiaomima.Text + "";
                    cmd.ExecuteNonQuery();
                    con.Close();
                    DialogResult dengluresult = MessageBox.Show("注销成功!!!");
                    if (dengluresult == DialogResult.OK)
                    {
                        textBox_zhuxiaozhanghao.Text = "";
                        textBox_zhuxiaomima.Text = "";
                        con.Close();
                    }
                }
                else
                {
                    MessageBox.Show("账号或者密码不正确!!!");
                }
            }
            else
            {
                MessageBox.Show("账号或者密码不能为空!!!");
            }
        }
    }
}

技术分享图片

五、登录成功界面程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace StudentSystem
{
    public partial class Form_login : Form
    {
        public Form_login()
        {
            InitializeComponent();
        }

        private void button_luruchengji_Click(object sender, EventArgs e)
        {
            Form_luruchengji form_luruchengji = new Form_luruchengji();
            this.Visible = false;
            form_luruchengji.ShowDialog();
        }

        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_denglu form_denglu = new Form_denglu();
            this.Visible = false;
            form_denglu.ShowDialog();
        }

        private void button_tuichuxitong_Click(object sender, EventArgs e)
        {
            this.Visible = false;
        }
        private void button_xianshichengji_Click(object sender, EventArgs e)
        {
            Form_scoretable form_scoretable = new Form_scoretable();
            this.Visible = false;
            form_scoretable.ShowDialog();
        }

        private void button_shanchuchengji_Click(object sender, EventArgs e)
        {
            Form_shanchuchengji form_shanchuchengji = new Form_shanchuchengji();
            this.Visible = false;
            form_shanchuchengji.ShowDialog();
        }

        private void button_xiugaichengji_Click(object sender, EventArgs e)
        {
            Form_xiugaichenji form_xiugaichenji = new Form_xiugaichenji();
            this.Visible = false;
            form_xiugaichenji.ShowDialog();
        }

        private void button_bianjikecheng_Click(object sender, EventArgs e)
        {
            Form_bianjikecheng form_bianjikecheng = new Form_bianjikecheng();
            this.Visible = false;
            form_bianjikecheng.ShowDialog();
        }
    }
}

技术分享图片

 六、录入成绩界面程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_luruchengji : Form
    {
        public Form_luruchengji()
        {
            InitializeComponent();
        }

        private void button_luru_Click(object sender, EventArgs e)
        {
            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            //将连接打开
            con.Open();
            //执行con对象的函数,返回一个SqlCommand类型的对象
            SqlCommand cmd = con.CreateCommand();
            //拼写语句
            cmd.CommandText = "insert into studentscore values(‘" + textBox_luruxuehao.Text + "‘,‘" + textBox_luruxingming.Text + "‘,‘" + textBox_lurushuxue.Text + "‘,‘" + textBox_luruyingyu.Text + "‘,‘" + textBox_luruyuwen.Text + "‘)";
            //增删改用ExecuteNonQuery,会返回一个整型数字
            int count = cmd.ExecuteNonQuery();
            if (count > 0)
            {
                DialogResult result = MessageBox.Show("录入成功!");
                if (result == DialogResult.OK)
                {
                    con.Close();
                    Form_login form_StudentMassage = new Form_login();
                    this.Visible = false;
                    form_StudentMassage.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("录入失败!");
            }
        }

        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_login form_StudentMassage = new Form_login();
            this.Visible = false;
            form_StudentMassage.ShowDialog();
        }
    }
}

技术分享图片

七、修改成绩界面

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_xiugaichenji : Form
    {
        public Form_xiugaichenji()
        {
            InitializeComponent();
        }

        private void button_quedingxiugaichengji_Click(object sender, EventArgs e)
        {
            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            //将连接打开
            con.Open();
            //执行con对象的函数,返回一个SqlCommand类型的对象
            SqlCommand cmd = con.CreateCommand();
            //把输入的数据拼接成sql语句,并交给cmd对象
            cmd.CommandText = "select *from studentscore where Student_Number=‘" + textBox_xiugaichengjixuehao.Text + "‘and Student_Name=‘" + textBox_xiugaichengjixingming.Text + "";

            //用cmd的函数执行语句,返回SqlDataReader对象dr,dr就是返回的结果集(也就是数据库中查询到的表数据)
            SqlDataReader dr = cmd.ExecuteReader();
            if (!String.IsNullOrEmpty(textBox_xiugaichengjixuehao.Text) && !String.IsNullOrEmpty(textBox_xiugaichengjixingming.Text))
            {
                //用dr的read函数,每执行一次,返回一个包含下一行数据的集合dr,在执行read函数之前,dr并不是集合
                if (dr.Read())
                {
                    //用完后关闭连接,以免影响其他程序访问
                    con.Close();
                    //将连接打开
                    con.Open();

                    cmd.CommandText = "update studentscore set Student_Math=‘" + textBox_xiugaichengjishuxue.Text + "‘,Student_English=‘"+ textBox_xiugaichengjiyingyu.Text + "‘,Student_Chinese=‘"+ textBox_xiugaichengjiyuwen.Text+ "‘where Student_Number=‘" + textBox_xiugaichengjixuehao.Text + "‘and Student_Name=‘" + textBox_xiugaichengjixingming.Text + "";
                    //增删改用ExecuteNonQuery,会返回一个整型数字
                    int count = cmd.ExecuteNonQuery();
                    if (count > 0)
                    {
                        DialogResult xiugairesult = MessageBox.Show("修改成绩成功!");
                        if (xiugairesult == DialogResult.OK)
                        {
                            Form_login form_StudentMassage = new Form_login();
                            this.Visible = false;
                            form_StudentMassage.ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("修改成绩失败!");
                    }
                    //用完后关闭连接,以免影响其他程序访问
                    con.Close();
                }
                else
                {
                    MessageBox.Show("学号或者姓名错误!!!");
                }
            }
            else
            {
                MessageBox.Show("学号或者姓名不能为空!!!");
            }
        }
        private void button_xiugaichengjifanhui_Click(object sender, EventArgs e)
        {
            Form_login form_StudentMassage = new Form_login();
            this.Visible = false;
            form_StudentMassage.ShowDialog();
        }
    }
}

技术分享图片

八、编辑课程程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace StudentSystem
{
    public partial class Form_bianjikecheng : Form
    {
        public Form_bianjikecheng()
        {
            InitializeComponent();
        }

        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_login form_login = new Form_login();
            this.Visible = false;
            form_login.ShowDialog();
        }

        private void button_tianjiakecheng_Click(object sender, EventArgs e)
        {
            Form_tianjiakecheng form_tianjiakecheng = new Form_tianjiakecheng();
            this.Visible = false;
            form_tianjiakecheng.ShowDialog();
        }

        private void button_shanchukecheng_Click(object sender, EventArgs e)
        {
            Form_shanchukecheng form_shanchukecheng = new Form_shanchukecheng();
            this.Visible = false;
            form_shanchukecheng.ShowDialog();
        }
    }
}

技术分享图片

九、添加课程程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_tianjiakecheng : Form
    {
        public Form_tianjiakecheng()
        {
            InitializeComponent();
        }

        private void button_queding_Click(object sender, EventArgs e)
        {
            string tableName = "studentscore";
            String sqlStr = "alter table " + tableName + " add " + textBox_kechen.Text + " varchar(10) null";
           
            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            con.Open();

            if (!String.IsNullOrEmpty(textBox_kechen.Text))
            { 
                //执行con对象的函数,返回一个SqlCommand类型的对象
                SqlCommand cmd = new SqlCommand(sqlStr, con);
               //执行sql命令
                cmd.ExecuteNonQuery();
               //关闭连接
                con.Close();
                DialogResult dengluresult = MessageBox.Show("添加课程成功!!!");
                if (dengluresult == DialogResult.OK)
                {
                    Form_bianjikecheng form_bianjikecheng = new Form_bianjikecheng();
                    this.Visible = false;
                    form_bianjikecheng.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("添加课程不能为空!!!");
            }
        }
        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_bianjikecheng form_bianjikecheng = new Form_bianjikecheng();
            this.Visible = false;
            form_bianjikecheng.ShowDialog();
        }
    }
}

技术分享图片

十、删除课程程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_shanchukecheng : Form
    {
        public Form_shanchukecheng()
        {
            InitializeComponent();
        }

        private void button_fanhui_Click(object sender, EventArgs e)
        {
            Form_bianjikecheng form_bianjikecheng = new Form_bianjikecheng();
            this.Visible = false;
            form_bianjikecheng.ShowDialog();
        }

        private void button_queding_Click(object sender, EventArgs e)
        {
            String sqlStr = "alter table studentscore drop column "  + textBox_shanchukecheng.Text ;

            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            con.Open();

            if (!String.IsNullOrEmpty(textBox_shanchukecheng.Text))
            {
                //执行con对象的函数,返回一个SqlCommand类型的对象
                SqlCommand cmd = new SqlCommand(sqlStr, con);
                //执行sql命令
                cmd.ExecuteNonQuery();
                //关闭连接
                con.Close();
                DialogResult dengluresult = MessageBox.Show("删除课程成功!!!");
                if (dengluresult == DialogResult.OK)
                {
                    Form_bianjikecheng form_bianjikecheng = new Form_bianjikecheng();
                    this.Visible = false;
                    form_bianjikecheng.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("课程不能为空!!!");
            }
        }
    }
}

技术分享图片

十一、显示成绩界面程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_scoretable : Form
    {
        public Form_scoretable()
        {
            InitializeComponent();

            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            //将连接打开
            con.Open();
            DataSet dataSet = new DataSet();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select *from studentscore",con);
            sqlDataAdapter.Fill(dataSet);
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.DataSource = dataSet.Tables[0];
            con.Close();
        }

        private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            //显示在HeaderCell上
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                DataGridViewRow r = this.dataGridView1.Rows[i];
                r.HeaderCell.Value = string.Format("{0}", i + 1);
            }
            this.dataGridView1.Refresh();
        }
    }
}

 技术分享图片

 

十二、删除学生成绩查询

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentSystem
{
    public partial class Form_shanchuchengji : Form
    {
        public Form_shanchuchengji()
        {
            InitializeComponent();
        }

        private void button_querenshanchu_Click(object sender, EventArgs e)
        {
            //创建数据库连接类的对象
            SqlConnection con = new SqlConnection(@"Data Source=CFF-PC;Initial Catalog=studentsystem;Integrated Security=True");
            //将连接打开
            con.Open();

            //执行con对象的函数,返回一个SqlCommand类型的对象
            SqlCommand cmd = con.CreateCommand();
            //把输入的数据拼接成sql语句,并交给cmd对象
            cmd.CommandText = "select*from studentscore where Student_Number=‘" + textBox_shanchuxuehao.Text + "‘and Student_Name=‘" + textBox_shanchuxingming.Text + "";
            //用cmd的函数执行语句,返回SqlDataReader对象dr,dr就是返回的结果集(也就是数据库中查询到的表数据)
            SqlDataReader dr = cmd.ExecuteReader();
            if (!String.IsNullOrEmpty(textBox_shanchuxuehao.Text) && !String.IsNullOrEmpty(textBox_shanchuxingming.Text))
            {
                //用dr的read函数,每执行一次,返回一个包含下一行数据的集合dr,在执行read函数之前,dr并不是集合
                if (dr.Read())
                {
                    con.Close();
                    con.Open();
                    //拼写语句
                    cmd.CommandText = "delete from studentscore where Student_Number=‘" + textBox_shanchuxuehao.Text + "‘and Student_Name=‘" + textBox_shanchuxingming.Text + "";
                    cmd.ExecuteNonQuery();
                    con.Close();
                    DialogResult dengluresult = MessageBox.Show("删除成功!!!");
                    if (dengluresult == DialogResult.OK)
                    {
                        con.Close();
                        Form_login form_StudentMassage = new Form_login();
                        this.Visible = false;
                        form_StudentMassage.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("学号或者姓名不正确!!!");
                }
            }
            else
            {
                MessageBox.Show("学号或者姓名不能为空!!!");
            }
            
        }

        private void button_shanchufanhui_Click(object sender, EventArgs e)
        {
            Form_login form_StudentMassage = new Form_login();
            this.Visible = false;
            form_StudentMassage.ShowDialog();
        }
    }
}

技术分享图片

 

 

以上是关于学生成绩管理系统的主要内容,如果未能解决你的问题,请参考以下文章

学生成绩管理系统c

c语言学生成绩管理系统1000行源代码

如何用Java语言编写学生成绩管理系统

基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写?

跪求C语言程序代码“学生成绩管理”

基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写?