login.aspx.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using SimpleExam.App_Code;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SimpleExam
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)     //IsPostBack是Page类有一个bool类型的属性,用来判断针对当前Form的请求是第一次还是非第一次请求。
            {
                cx.Items.Add("管理员");      //如果不是POST提交(也就是第一次进入该页面),则初始化页面或控件等等
                //cx.Items.Add("考生");            //cx是下拉框的id

            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox2.Text.ToString().Trim() == "" || TextBox1.Text.ToString().Trim() == "" || yzm.Text.ToString().Trim() == "")
            {
                Response.Write("<script>javascript:alert('请输入完整');location.href='login.aspx';</script>");
                Response.End();                                   //终止执行下面的语句
            }
            if (Session["code"].ToString().Trim().Equals(yzm.Text.Trim()))             //将验证码存在session里,放入的是验证码的信息
            {

            }
            else
            {
                Response.Write("<script>javascript:alert('验证码有误');location.href='login.aspx';</script>");
                Response.End();
            }


            //判断对应的管理员和考生是否在数据库中
            string sql = "";
            if (cx.Text.ToString().Trim() == "管理员")
            {
                sql = "select * from allusers where username='" + TextBox1.Text.ToString().Trim() + "' and pwd='" + TextBox2.Text.ToString().Trim() + "' ";
            }
            if (cx.Text.ToString().Trim() == "考生")
            {
                sql = "select * from kaoshengxinxi where zhunkaozhenghao='" + TextBox1.Text.ToString().Trim() + "' and mima='" + TextBox2.Text.ToString().Trim() + "' ";
            }

            DataSet result = new DataSet();
            result = new Class1().hsggetdata(sql);    //实例化一个新类,调用里面的方法,传入sql语句,最后返回的是 一个结果集 dataset 类型的
            // result = new TestOnline.Class1().hsggetdata(sql);
            if (result != null)
            {
                if (result.Tables[0].Rows.Count > 0)     //检查dataset里面有没有记录,为真是有记录 为假是没有记录
                {
                    //设置session中username等于textbox1.的text属性去掉空格后的值
后面还有 28 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。