Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string  loginName = Session["userID"].ToString();
         Usersmr user      = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
         GridViewBind();
     }
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string  loginName = Session["userID"].ToString();
         Usersmr user      = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
         InitDDLData();  //初始化考试科目
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string  loginName = Session["userID"].ToString();
         Usersmr user      = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
         GridViewBind();
     }
     ImageButtonResetPassword.Attributes.Add("onClick", "javascript:return confirm('确定重置密码?');");
     ImageButtonDelete.Attributes.Add("onclick", "javascript:return confirm('确定删除?');");
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string  loginName = Session["userID"].ToString();
         Usersmr user      = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
         this.txtDepartmentId.Attributes.Add("nullable", "yes");    //是否为空
         this.txtDepartmentName.Attributes.Add("nullable", "yes");  //是否为空
         this.imgBtnSave.Attributes["onclick"] = "javascript:return verifyAll(window.Form1);";
     }
 }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         InitData();      //初始化科目列表框
         ScoreInitData(); //初始化成绩
         labUser.Text = Session["userID"].ToString();
         Usersmr user   = new Usersmr();
         string  userid = Session["userID"].ToString();
         user.LoadData(userid);
         lblName.Text = user.UserName;
     }
 }
Exemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //应用Session对象存储用户名
         string loginName = Session["userID"].ToString();
         //实例化公共类Usersmr
         Usersmr user = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
         //调用自定义方法绑定数据库中试题信息
         PaperData();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string  loginName = Session["userID"].ToString();
         Usersmr user      = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
         InitDDLData();             //初始化考试科目下拉列表框
         if (Request["ID"] != null) //如果是修改题目,初始化数据
         {
             InitData();
         }
     }
 }
Exemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Convert.ToString(Session["userID"]) == null)
     {
         Response.Write("<script language=javascript>location='Login.aspx'</script>");
     }
     if (!Page.IsPostBack)
     {
         this.txtOldPwd.Focus();
         string  loginName = Session["userID"].ToString();
         Usersmr user      = new Usersmr();
         user.LoadData(loginName);
         labUser.Text = user.UserName;
     }
 }
Exemplo n.º 9
0
    protected void ImgStartExam_Click(object sender, ImageClickEventArgs e)
    {
        Usersmr user = new Usersmr();

        if (user.IsTest(Session["userID"].ToString().Trim(), Convert.ToInt32(ddlPaper.SelectedValue)))
        {
            lblMessage.Text = "您已经考试过了,不能再考试!";
        }
        else
        {
            Session["PaperID"]   = ddlPaper.SelectedValue;
            Session["PaperName"] = ddlPaper.SelectedItem.Text;
            Response.Redirect("UserTest.aspx");    //转向考试界面
        }
    }
Exemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //应用Session记录用户ID号
         string loginName = Session["userID"].ToString();
         //实例化公共类Usersmr
         Usersmr user = new Usersmr();
         user.LoadData(loginName);
         //显示登录的用户角色
         labUser.Text = user.UserName;
         //调用自定义方法InitData()进行权限设置
         InitData();
     }
 }
Exemplo n.º 11
0
    protected void ImageButtonResetPassword_Click(object sender, ImageClickEventArgs e)
    {
        int numOfChecked = 0;

        for (int i = 0; i < this.GridView1.Rows.Count; i++)
        {
            bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("chkSelected")).Checked;
            if (isChecked)
            {
                numOfChecked++;
            }
        }
        if (numOfChecked == 1)
        {
            for (int i = 0; i < this.GridView1.Rows.Count; i++)
            {
                bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("chkSelected")).Checked;
                if (isChecked)
                {
                    string UserID = ((Label)GridView1.Rows[i].FindControl("Label1")).Text;

                    Random ran         = new Random();
                    string newPassword = (ran.Next(999999).ToString().PadLeft(6, '8')); //随机生成一个密码

                    Usersmr user   = new Usersmr();                                     //创建Usersmr对象user
                    string  pwdMd5 = user.GetMd5(newPassword);
                    user.UserPwd = pwdMd5.ToString().Trim();
                    if (user.ModifyPassword(UserID))//更改用户密码
                    {
                        Response.Write("<Script language=JavaScript>alert('" + UserID + "的密码已经重置,新密码为【" + newPassword + "】。');location='UserManage.aspx';</Script>");
                    }
                    else//修改密码失败
                    {
                        Response.Write("<Script language=JavaScript>alert('" + UserID + "重置密码失败!');location='UserManage.aspx';</Script>");
                    }
                }
                else
                {
                    isChecked = false;//取消选中
                }
            }
        }
        else
        {
            Response.Write("<Script language=JavaScript>alert('您只能选择一个用户!');;location='UserManage.aspx';</Script>");
            return;
        }
    }
Exemplo n.º 12
0
    //GridView控件RowDeleting事件
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string  userID = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); //取出要删除记录的主键值
        Usersmr user   = new Usersmr();                                       //创建Usersmr类对象user

        if (user.DeleteByProc(userID))                                        //根据主键使用DeleteByProc方法删除用户
        {
            ajaxDialog.OpenDialogForPage(Page, "删除成功!");
        }
        else
        {
            ajaxDialog.OpenDialogForPage(Page, "删除失败!");
        }
        GridView1.EditIndex = -1;
        GridViewBind();//重新绑定数据
    }
Exemplo n.º 13
0
    //GridView控件RowUpdating事件
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string  userID = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); //取出记录的主键值
        Usersmr user   = new Usersmr();

        user.UserName     = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("tbxName")).Text;
        user.RoleId       = Convert.ToInt32(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlRole")).SelectedValue);       //取出修改后的值
        user.DepartmentId = Convert.ToInt32(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDepartment")).SelectedValue); //取出修改后的值
        if (user.UpdateByProc(userID))                                                                                              //使用Usersmr类UpdateByProc方法修改用户信息
        {
            GridViewBind();
            ajaxDialog.OpenDialogForPage(Page, "修改成功!");
        }
        else
        {
            ajaxDialog.OpenDialogForPage(Page, "修改失败!");
        }
        GridView1.EditIndex = -1;
        GridViewBind();
    }
Exemplo n.º 14
0
    //登录按钮事件
    protected void imgBtnLogin_Click(object sender, ImageClickEventArgs e)
    {
        Usersmr user = new Usersmr();//创建Usersmr对象user
        //调用自定义GetMd5加密方法
        string pwdMd5 = user.GetMd5(txtPwd.Text.ToString());

        //判断验证码是否正确
        if (Session["CheckCode"].ToString() != Validator.Text.Trim())
        {
            //显示错误信息
            lblMessage.Text = "验证码错误!";
        }
        else
        {
            if (user.CheckPassword(txtUserID.Text.Trim())) //根据用户编号查询用户密码
            {
                if (user.UserPwd == pwdMd5)                //输入密码与用户密码相同
                {
                    if (object.Equals(Request.Cookies["UserID"], null))
                    {
                        //调用自定义方法 CreateCookie()存储用户名
                        CreateCookie();
                    }
                    else
                    {
                        CreateCookie();
                    }
                    Session["userID"] = txtUserID.Text.Trim(); //存储用户编号
                    Response.Redirect("Default.aspx");         //转向管理员操作界面
                }
                else//密码错误,给出提示
                {
                    lblMessage.Text = "您输入的密码错误!";
                }
            }
            else//用户不存在,给出提示
            {
                lblMessage.Text = "该用户不存在!";
            }
        }
    }
Exemplo n.º 15
0
 protected void ImageButtonDelete_Click(object sender, ImageClickEventArgs e)
 {
     for (int i = 0; i < this.GridView1.Rows.Count; i++)
     {
         bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("chkSelected")).Checked;
         if (isChecked)
         {
             string  userID = ((Label)GridView1.Rows[i].FindControl("Label1")).Text;
             Usersmr user   = new Usersmr(); //创建Usersmr类对象user
             if (user.DeleteByProc(userID))  //根据主键使用DeleteByProc方法删除用户
             {
                 Response.Write("<script language=javascript>alert('删除成功!');location='UserManage.aspx';</script>");
             }
             else
             {
                 Response.Write("<script language=javascript>alert('" + userID + "删除失败!');location='UserManage.aspx';</script>");
             }
         }
     }
     GridViewBind();
 }