基本信息
源码名称:C# 考试管理系统源码(含access数据库)
源码大小:0.84M
文件格式:.zip
开发语言:C#
更新时间:2019-05-22
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 1 元 
   源码介绍
考试管理系统可以连接数据库


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.OleDb;

namespace chenxiang
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.comboBox1.Items.Add("管理员");
            this.comboBox1.Items.Add("教师");
            this.comboBox1.Items.Add("学生");
            this.comboBox1.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            user.tBox1=(this.textBox1.Text).ToString();
            user.cBox1 = this.comboBox1.SelectedItem.ToString();

            string uname = this.textBox1.Text.ToString();
            string passwd = this.textBox2.Text.ToString();
            string ustype = this.comboBox1.SelectedItem.ToString();
            if(ustype.Equals("管理员")){
                if (checkuesr(uname, passwd))
                {
                    Form2 obj = new Form2();
                    obj.Show();
                    this.Hide();
                }
                else {
                    MessageBox.Show("用户名或密码错误");
                }
            }
            else if (ustype.Equals("教师"))
            {                
                    MessageBox.Show("正在建设中");
            }
            else {
                MessageBox.Show("正在建设中");
                Form2 obj = new Form2();
                obj.Show();
                this.Hide();
            }

            
        }
        public bool checkuesr(string _un,string _pwd) {
            bool flag=false;           
            string sql = string.Format("select count(*)from Admin where LoginID='{0}' and LOginPwd='{1}'",_un,_pwd);
            OleDbCommand cmd = new OleDbCommand(sql, DBhp.con);
            int i = 0;
            try
            {
                DBhp.con.Open();
                i = (int)cmd.ExecuteScalar();
                if (i == 1)
                {
                    flag = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
            finally {
                DBhp.con.Close();
            }

            return flag;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}