admin管理员组

文章数量:1531746

用visual studio编写的宿舍管理系统
链接:https://pan.baidu/s/1Idkf9tdne1G0bDyIoZFJYw
提取码:0vcs


前言

本篇是小编本学期的课程设计,做的一般,大家看看就好了,仅供参考


提示:以下是本篇文章正文内容,下面案例可供参考

一、项目使用说明

采用c#语言编写,使用的软件是Start Experimental Instance of Visual Studio 2019
下载代码后可直接使用Visual Studio打开,点击右下角的sln文件,点击开始就可以运行了

二、设计思路

1.分为老师系统和学生系统

运行开始后可自行选择登陆或者注册

按钮代码如下(仅为跳转页面代码):

private void 学生端ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            学生注册 s = new 学生注册();
            this.Close();
            s.Show();
        }

        private void 老师端ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            老师注册 s = new 老师注册();
            this.Close();
            s.Show();
        }

2.注册代码

先判断是否为空,再判断两次输入的密码是否一致

代码如下:

private void button2_Click(object sender, EventArgs e)
        {
            String name = textBox1.Text;
            String phone = textBox2.Text;
            String dorm = textBox3.Text;
            String cipher = textBox4.Text;
            String cipher1 = textBox5.Text;

            if (textBox1.Text == string.Empty || textBox2.Text == string.Empty || textBox3.Text == string.Empty || textBox4.Text == string.Empty || textBox5.Text == string.Empty)
            {
                MessageBox.Show("请填写完整", "警告", MessageBoxButtons.OK);
                return;
            }
            else if (textBox4.Text != textBox5.Text)
            {
                MessageBox.Show("两次密码输入不相同,请重新输入", "警告", MessageBoxButtons.OK);
                return;
            }
            else
            {
                using (SqlConnection conn = new SqlConnection(connStr))
                {
                    string sql = "insert into teacher values(@name,@dorm,@phone,@cipher)";
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        SqlParameter[] sps ={
                            new SqlParameter("@name",name),
                            new SqlParameter("@phone",phone),
                            new SqlParameter("@dorm",dorm),
                            new SqlParameter("@cipher",cipher)
                        };
                        cmd.Parameters.AddRange(sps);
                        conn.Open();

                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            MessageBox.Show("注册成功", "警告", MessageBoxButtons.OK);
                            老师登录 abc = new 老师登录();
                            this.Hide();
                            abc.Show();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("注册失败");
                            return;
                        }
                    }

数据库方面建表如下:

可以自行添加主键


总结

仅为课设方面使用,做的比较粗糙

本文标签: 管理系统宿舍VisualStudio