在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → C# 考试管理系统源码下载(含教师、学生、管理员三个角色入口)

C# 考试管理系统源码下载(含教师、学生、管理员三个角色入口)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:7.17M
  • 下载次数:278
  • 浏览次数:3986
  • 发布时间:2016-12-01
  • 实例类别:C#语言基础
  • 发 布 人:bala
  • 文件格式:.zip
  • 所需积分:5
 相关标签: 系统

实例介绍

【实例简介】

考试管理系统 首先要 附加Ctgu 这个数据库,然后 将 dbhelper.cs中的 连接串 改成本机的,即可测试了

管理员账号:admin 密码 admin1

教师账号:t002 密码 12345

学生账号:

【实例截图】

【核心代码】

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 MySchool
{
    /// <summary>
    /// 登录窗体
    /// </summary>
    public partial class LoginForm : Form
    {
        public LoginForm()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 登录类型属性
        /// </summary>
        public string LoginType {
            get {
                return this.cboLoginType.Text;
            }
        }
        /// <summary>
        /// 登录帐号属性
        /// </summary>
        public string LoginId {
            get {
                return txtLoginId.Text.Trim();
            }
        }

        // “登录”按钮的单击事件
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (!chkInput()) return; //检查输入

            string loginType = cboLoginType.Text;
            Form firform = null;

            switch (loginType)
            {
                case "教师":
                    if (TeacherLogin())
                        firform = new TeacherForm();
                    break;
                case "管理员":
                    if (AdminLogin())
                        firform = new AdminForm();
                    break;
                case "学生":
                    if (StudentLogin())
                        firform = new StudentForm();
                    break;

            }
           
            if (firform!=null)
            {
                this.Hide();
                firform.ShowDialog();
               
            }
            else
            {
                MessageBox.Show("登录失败,请检查帐号或密码是否有误!", "CTGU在线考试系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

           
        }

        private bool StudentLogin()
        {
            UserHelper.loginId = txtLoginId.Text;

            string strsql = string.Format("select count(*) from {2} where StudentNO='{0}' and Pwd='{1}'", txtLoginId.Text, txtLoginPwd.Text, "Student");
            SqlCommand comm = new SqlCommand(strsql, DBHelper.connection);
            try
            {
                DBHelper.connection.Open();
                int result = (int)comm.ExecuteScalar();
               
                    
                    return result > 0;
              
            }
            catch
            {
                return false;
            }
            finally
            {
                DBHelper.connection.Close();
            }
        }

        private bool AdminLogin()
        {
            UserHelper.loginId = txtLoginId.Text;
           string strsql = string.Format("select count(*) from {2} where AdminId='{0}' and Pwd='{1}'", txtLoginId.Text, txtLoginPwd.Text, "Admin");
            SqlCommand comm = new SqlCommand(strsql, DBHelper.connection);
            try
            {
                DBHelper.connection.Open();
                int result = (int)comm.ExecuteScalar();
                return result > 0;
            }
            catch
            {
                return false;
            }
            finally
            {
                DBHelper.connection.Close();
            }
        }
       
        private bool TeacherLogin()
        {
            UserHelper.loginId = txtLoginId.Text;
           string strsql = string.Format("select count(*) from {2} where TeacherId='{0}' and Pwd='{1}'", txtLoginId.Text, txtLoginPwd.Text, "Teacher");
            SqlCommand comm = new SqlCommand(strsql, DBHelper.connection);
            try
            {
                DBHelper.connection.Open();
                int result = (int)comm.ExecuteScalar();
                return result > 0;
            }
            catch
            {
                return false;
            }
            finally
            {
                DBHelper.connection.Close();
            }
        }
        /// <summary>
        /// 主要用于校验客户端的输入的合法性
       
        private bool chkInput()
        {
            string accountId = txtLoginId.Text.Trim();
            string pwd = txtLoginPwd.Text;

            if (accountId == "")
            {
                MessageBox.Show("帐号不允许为空!", "CTGU在线考试系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            if (pwd == "")
            {
                MessageBox.Show("请输入密码!", "CTGU在线考试系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            string loginType = cboLoginType.Text;

            if (loginType == "")
            {
                MessageBox.Show("请选择登陆类型!", "CTGU在线考试系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            return true;

        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            StudentRegister sr = new StudentRegister();
            this.Hide();
            sr.Show();
              
        }
    }
}

标签: 系统

实例下载地址

C# 考试管理系统源码下载(含教师、学生、管理员三个角色入口)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

第 1 楼 墨竹199709 发表于: 2017-04-13 08:58 06
三大的学长吗?

支持(0) 盖楼(回复)

第 2 楼 墨竹199709 发表于: 2017-04-13 08:58 20
三大的学长吗?

支持(0) 盖楼(回复)

第 3 楼 张发刚 发表于: 2020-06-20 16:29 34
登不上去

支持(0) 盖楼(回复)

发表评论

(您的评论需要经过审核才能显示)

查看所有3条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警