⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rolemanage.aspx.cs

📁 发一个功能比较全面的考试系统(VS2005+SQL2000)本系统开发环境是VS2005+SQL2000,是我在实习单位时独立做的一个项目
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OnLineExam.BusinessLogicLayer;

public partial class Web_RoleManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string loginName = Session["userID"].ToString();
            Users user = new Users();
            user.LoadData(loginName);
            labUser.Text = user.UserName;
            InitData();
        }
    }
    private void InitData()
    {
        DataTable dt = Role.Query(new Hashtable());
        GV.DataSource = dt;
        GV.DataBind();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            //部门管理
            if (OnLineExam.DataAccessHelper.GetSafeData.ValidateDataRow_N(dt.Rows[i], "HasDuty_DepartmentManage") == 1)
                ((CheckBox)GV.Rows[i].FindControl("chkDepartmentManage")).Checked = true;

            //用户管理
            if (OnLineExam.DataAccessHelper.GetSafeData.ValidateDataRow_N(dt.Rows[i], "HasDuty_UserManage") == 1)
                ((CheckBox)GV.Rows[i].FindControl("chkUserManage")).Checked = true;

            //考试科目管理
            if (OnLineExam.DataAccessHelper.GetSafeData.ValidateDataRow_N(dt.Rows[i], "HasDuty_CourseManage") == 1)
                ((CheckBox)GV.Rows[i].FindControl("chkCourseManage")).Checked = true;

            //试卷制定维护
            if (OnLineExam.DataAccessHelper.GetSafeData.ValidateDataRow_N(dt.Rows[i], "HasDuty_PaperSetup") == 1)
                ((CheckBox)GV.Rows[i].FindControl("chkPaperSetup")).Checked = true;

            //用户试卷管理
            if (OnLineExam.DataAccessHelper.GetSafeData.ValidateDataRow_N(dt.Rows[i], "HasDuty_UserPaperList") == 1)
                ((CheckBox)GV.Rows[i].FindControl("chkUserPaperList")).Checked = true;

            //试题类别管理
            if (OnLineExam.DataAccessHelper.GetSafeData.ValidateDataRow_N(dt.Rows[i], "HasDuty_SingleSelectManage") == 1)
                ((CheckBox)GV.Rows[i].FindControl("chkTypeManage")).Checked = true;

            

        }
    }
    protected void ImageButtonGiant_Click(object sender, ImageClickEventArgs e)
    {
        Hashtable ht = new Hashtable();
        string where = "";

        foreach (GridViewRow row in GV.Rows)
        {
            ht.Clear();
            ht.Add("HasDuty_DepartmentManage", ((CheckBox)row.FindControl("chkDepartmentManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_UserManage", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_RoleManage", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_Role", ((CheckBox)row.FindControl("chkUserManage")).Checked == true ? 1 : 0); 
            ht.Add("HasDuty_CourseManage", ((CheckBox)row.FindControl("chkCourseManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_PaperSetup", ((CheckBox)row.FindControl("chkPaperSetup")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_PaperLists", ((CheckBox)row.FindControl("chkPaperSetup")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_UserPaperList", ((CheckBox)row.FindControl("chkUserPaperList")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_UserScore", ((CheckBox)row.FindControl("chkUserPaperList")).Checked == true ? 1 : 0);

            ht.Add("HasDuty_SingleSelectManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_MultiSelectManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_FillBlankManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_JudgeManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);
            ht.Add("HasDuty_QuestionManage", ((CheckBox)row.FindControl("chkTypeManage")).Checked == true ? 1 : 0);

            where = " Where RoleId=" + row.Cells[0].Text;
            Role.Update(ht, where);
        }
    }
    protected void GV_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GV.PageIndex = e.NewPageIndex;
        InitData();
    }
    protected void GV_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        int i;
        //执行循环,保证每条数据都可以更新
        for (i = 0; i < GV.Rows.Count; i++)
        {
            //首先判断是否是数据行
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='Aqua'");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -