毕业设计之软件开发(6)-考试系统

发布时间 2023-10-27 18:02:32作者: 奔跑的小蚂蚁9538

  本项目主要实现在线考试,分为管理员和考试人员两种角色,管理员可以出题,上传试题,随即组卷,批阅试卷,下载试卷,考试科目的设置,考试人员主要是在线考试和查看排名信息!开发工具vs2010+sqlserver2008。和以往一样,先发一下效果图。整理总结不易,如需全部代码,请联系我15098950589(微信同号)。

  

 

 核心代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNet.FrameWork.Data;

namespace ExamManager
{
public partial class Login : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

}

protected void smt_login_Click(object sender, EventArgs e)
{
App_SQL.SqlHelper help = new App_SQL.SqlHelper();
string name = txtname.Text.Trim();
string pwd = txtpwd.Text.Trim();
string password = help.Code(pwd);
string text = DropDownList1.Text;
int value = int.Parse(DropDownList1.SelectedValue);
if (DbHelperSQL.GetExists("select * from S_User where U_LoginName='" + name + "' and U_Password='" + password + "' and U_RoleID='" + value + "'"))
{
int userid = int.Parse(DbHelperSQL.GetSingle("select U_UserID from S_User where U_LoginName='" + name + "'").ToString());
if (value == 1)
{
Session.Clear();
Session["Teacher"] = name;
Session["UserID"] = userid;
Response.Redirect("~/Index.aspx");
}
else if (value == 2)
{
Session.Clear();
Session["Admin"] = name;
Session["UserID"] = userid;
Response.Redirect("~/Index.aspx");
}
else
{
Session.Clear();
Session["Admin"] = name;
Session["UserID"] = userid;
Response.Redirect("~/Index.aspx");
}
}
else
{
Response.Write("<script>alert('登录失败')</script>");
}
}
}
}