Пример #1
0
    public static DataTable studentList = new DataTable(); //定义一个Table表格,初始化为null.
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie usercookie = Request.Cookies["nowloginuser"];
        string     url        = PublicClass.CheckLogin(usercookie, "main");

        if (url != "")
        {
            Response.Write(url);
            return;
        }
        if (!IsPostBack)
        {
            this.BjName.Items.Clear();
            this.BjName.Items.Add("请选择...");
            List <TbClass> TbClass = TbClassManager.GetAllClassList();
            foreach (TbClass TbClassRow in TbClass)
            {
                string AddList = TbClassRow.Nj + TbClassRow.BjName;
                this.BjName.Items.Add(AddList);
            }
            string yhid = Request["userid"];
            if (yhid != null)
            {
                TbStudentManager.DeleteStuByYuID(int.Parse(yhid));
            }
            Load_Student();
        }
    }
Пример #2
0
    static int FirstSxNum = 0;/*声明变量,初始化为0,用于判断筛选条件是否改变*/

    /// <summary>
    /// 加载科目列表信息
    /// </summary>
    /// <param name="apge">当前页面</param>
    public void Load_Student()
    {
        string Bj_Name = txtClassName.Value.Trim() == "按姓名,学号,班级,用户名模糊查询" ? "" : txtClassName.Value.Trim();

        if (Bj_Name != "按姓名,学号,班级,用户名模糊查询" && Bj_Name != "" && FirstSxNum == 0)
        {
            page       = 1;
            FirstSxNum = 1;
        }
        studentList = TbStudentManager.GetAllStuInfo(len, page, Bj_Name);
        Count       = TbStudentManager.GetAllStuInfo(Bj_Name).Rows.Count;
        if (Count == 0)
        {
            Maxapge = 1;
        }
        else
        {
            if (Count % len == 0) //当数据库数据能整除10,最大页面数取Count/len的商
            {
                Maxapge = Count / len;
            }
            else
            {
                Maxapge = Count / len + 1;//当数据库数据不能整除10,最大页面数取Count/len的商+1.
            }
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string     name       = "";
        HttpCookie usercookie = Request.Cookies["nowloginuser"];
        string     url        = PublicClass.CheckLogin(usercookie, "");

        if (url != "")
        {
            Response.Redirect(url);
        }
        if (!IsPostBack)
        {
            string action = Request["action"];
            if (action != null && action.ToString().Equals("Del"))
            {
                int kgtid = int.Parse(Request["kgtid"].ToString());
                deleteGetTestPaperInfo(kgtid);
            }
            else if (action != null && action.ToString().Equals("vlaues"))
            {
                name = Request["sjName"].ToString();
            }
            spannowtime.InnerText = "服务器时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            string user = usercookie.Value;
            yhid = TbUserManager.GetStudentID(user);
            testPaperScoreList = TbScoreManager.GetTestPaperScoreByYhid(yhid, name);
            sjName.Value       = name;

            Hello = TbStudentManager.GetStudentByID(yhid).XsName;
        }
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string     sjName     = "";
        HttpCookie usercookie = Request.Cookies["nowloginuser"];
        string     url        = PublicClass.CheckLogin(usercookie, "");

        if (url != "")
        {
            Response.Redirect(url);
        }

        if (!IsPostBack)
        {
            string action = Request["action"];
            if (action != null && action.ToString().Equals("Elspenvlaues"))
            {
                sjName = Request["sjName"].ToString();
            }
            spannowtime.InnerText = "服务器时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            string user = usercookie.Value;
            Tobj.YhID = TbUserManager.GetStudentID(user);
            TbStudent tStudent = TbStudentManager.GetStudentByID(Tobj.YhID);
            testPaperList = TbTestPaperManager.GetAllTestpaperByPages(len, page, sjName, 2);
            Hello         = tStudent.XsName;
            Elspen.Value  = sjName;
        }
    }
Пример #5
0
    /// <summary>
    /// 根据用户ID查询对应详细信息
    /// </summary>
    /// <param name="YhID"></param>
    public void GetStudent(int YhID)
    {
        TbStudent student = TbStudentManager.GetStudentByID(YhID);
        TbUser    user    = TbUserManager.GetAllUser(YhID);
        string    message = student.YhID + "," + student.XsName + "," + student.XsSex + "," + student.BjName + "," + student.Remark + "," + user.YhName + "," + user.Xh + "," + user.YhPwd;

        Response.Write(message);
    }
    /// <summary>
    /// 导入用户
    /// </summary>
    protected void BeginImport_Click(object sender, EventArgs e)
    {
        string path = "";

        if (FileUpload1.PostedFile != null)
        {
            path = FileUpload1.PostedFile.FileName;
        }
        if (path == "")
        {
            lblImportResult.Text = "请选择导入文件!";
            return;
        }
        if (!path.Contains(':') || !path.Contains('\\'))
        {
            lblImportResult.Text = "请设置您当前浏览器:工具-internet选项-安全-自定\n义级别-将文件上传到服务器是包含本地路径!";
            return;
        }
        string hzm = path.Substring(path.LastIndexOf('.') + 1);

        if (hzm != "xls" && hzm != "xlsx")
        {
            lblImportResult.Text = "本系统只支持excel文件格式导入,可以参考下面摸板!";
            return;
        }
        TbUser    user = null;
        TbStudent stu  = null;
        DataSet   ds   = ExcelToDataSet(path);

        foreach (DataTable table in ds.Tables)
        {
            foreach (DataRow row in table.Rows)
            {
                user        = new TbUser();
                user.Xh     = row[3].ToString();
                user.YhName = row[4].ToString();
                user.YhPwd  = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(row[5].ToString(), "MD5");
                user.Zt     = 3;
                int userIdentity = TbUserManager.AddUser(user);
                if (userIdentity > 0)
                {
                    stu        = new TbStudent();
                    stu.XsName = row[0].ToString();
                    stu.XsSex  = row[1].ToString();
                    stu.YhID   = userIdentity;
                    stu.BjName = row[2].ToString();
                    stu.Remark = "";
                    int stuIdentity = TbStudentManager.AddStudent(stu);
                }
            }
        }
        lblImportResult.Text = "导入成功!";
    }
    /// <summary>
    /// 导出学生信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BtnExport_Click(object sender, EventArgs e)
    {
        string path = Server.MapPath("file") + "\\studentinfo.xls";

        if (File.Exists(path))
        {
            File.Delete(path);
        }
        DataTable dt = TbStudentManager.GetAllStuInfo();

        PublicClass.SaveToFile(PublicClass.GetTable(dt, "学员信息"), Server.MapPath("file") + "\\studentinfo.xls");
        Response.Redirect("file/studentinfo.xls");
    }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Ls = new List <string>();
        if (!IsPostBack)
        {
            if (Request["sjid"] != null)
            {
                SjID = Request["sjid"].ToString();
            }
        }
        DataTable dtPaper = TbTestPaperManager.getOnePaperInfo(SjID);

        if (dtPaper != null)
        {
            drPaper = dtPaper.Rows[0];
            DateTime Jstime = DateTime.Parse(drPaper["JsTime"].ToString());     //结束时间
            DateTime Kstime = DateTime.Parse(drPaper["KsTime"].ToString());     //开始时间
            int      Min    = PublicClass.GetMinutes(Kstime, Jstime);           //间隔时间
            Ls.Add(Min.ToString());                                             //Ls[0] = 剩余时间 分钟数
            if (STimeMin == -1)
            {
                STimeMin = Min;
            }
            int Zfen = TbQuestionTypesManager.GetSumScoreBySjid(int.Parse(SjID));
            Ls.Add(Zfen.ToString());
            string KstrTime = drPaper["KsTime"].ToString();
            KstrTime = KstrTime.Substring(KstrTime.LastIndexOf(' '));
            Ls.Add(KstrTime);
        }

        HttpCookie ck     = Request.Cookies["nowloginuser"];
        string     user   = ck.Value;//获得当前登录用户用户名
        int        YhID   = TbUserManager.GetStudentID(user);
        string     XsName = TbStudentManager.GetStudentByID(YhID).XsName;

        Ls.Add(XsName);


        ScoreZt = TbScoreManager.getScore(YhID.ToString(), SjID).Zt;
        if (ScoreZt == 2)
        {
            //ScriptManager.RegisterStartupScript(Page, typeof(string), "3", "error()", true);
            Response.Write("<script>alert('本次考试已结束,请勿重复提交');</script>");
            Response.Write("<script>window.close();</script>");
            return;
        }
    }
Пример #9
0
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        TbUser    User    = new TbUser();
        TbStudent Student = new TbStudent();

        User.YhName    = this.TextYh.Text;
        User.Xh        = this.textStudentID.Text;
        User.Zt        = 3;
        Student.XsName = this.TextName.Text;
        Student.BjName = this.BjName.Text;
        if (this.RadButNan.Checked)
        {
            Student.XsSex = this.RadButNan.Value;
        }
        else
        {
            Student.XsSex = this.RadButNv.Value;
        }
        Student.Remark = this.textBz.Text;
        if (this.HiddenYhID.Value == "")
        {
            this.BjName.Text = "请选择...";
            User.YhPwd       = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextMm.Text, "MD5");
            TbUserManager.SeeUser(User);
            Student.YhID = TbUserManager.AddUser(User);
            TbStudentManager.AddStudent(Student);
            Load_Student();
        }
        else
        {
            User.YhPwd   = this.TextMm.Text.Trim();
            User.YhID    = int.Parse(this.HiddenYhID.Value);
            Student.YhID = int.Parse(this.HiddenYhID.Value);
            TbUserManager.SetUser(User);
            TbStudentManager.SetStudent(Student);
            this.HiddenYhID.Value = "";
        }
        this.textStudentID.Text = "";
        this.TextYh.Text        = "";
        this.TextName.Text      = "";
        this.textBz.Text        = "";
        this.BjName.Text        = "请选择...";
        this.RadButNan.Checked  = true;
        Load_Student();
    }
Пример #10
0
 /// <summary>
 /// 清空学生信息j
 /// </summary>
 protected void ClearBtn_Click(object sender, EventArgs e)
 {
     TbStudentManager.DeleteAllStu();
     TbUserManager.DeleteAllStuUser();
     lblClear.Text = "学员以全部清空!";
 }