RoleLevelManager.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:5k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Text;
  12. public partial class RoleManager : System.Web.UI.Page
  13. {
  14.     Model.User_Priv MyMUP = new Model.User_Priv();
  15.     BLL.User_Priv MyBUP = new BLL.User_Priv();
  16.     /// <summary>
  17.     /// 模板
  18.     /// </summary>
  19.     List<Model.ASPClass> LMUP = new List<Model.ASPClass>();
  20.     /// <summary>
  21.     /// 业务
  22.     /// </summary>
  23.     BLL.ASPClass BUP = new BLL.ASPClass();
  24.     public string User_Priv_List = "";
  25.     protected void Page_Load(object sender, EventArgs e)
  26.     {
  27.         LoginLogic.MatchLoad("", "RoleManager");
  28.         if (!IsPostBack)
  29.         {
  30.             if (Request.QueryString["id"] != null)
  31.             {
  32.                 MyMUP = MyBUP.GetModel(int.Parse(Request.QueryString["id"].ToString()));
  33.                 User_Priv_List = MyMUP.FuncIdStr;
  34.                 MyDataBind(1);
  35.             }
  36.           
  37.         }
  38.         MyMUP = MyBUP.GetModel(int.Parse(Request.QueryString["id"].ToString()));
  39.         User_Priv_List = MyMUP.FuncIdStr;
  40.     }
  41.     public bool IsHaveExcept(string ClassName)
  42.     {
  43.         bool IsCannotUse = false;
  44.        // Model.Users MU = new BLL.Users().GetModel(int.Parse(SessionInclude.Id));
  45.         Model.User_Priv MUP = new BLL.User_Priv().GetModel(int.Parse(Request.QueryString["id"] .ToString()));//MU.PrivId);
  46.         string[] QXStr = MUP.FuncIdStr.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  47.         foreach (string QX in QXStr)
  48.         {
  49.             if (QX == ClassName)
  50.             {
  51.                 IsCannotUse = true;
  52.                 break;
  53.             }
  54.         }
  55.         return IsCannotUse;
  56.     }
  57.     /// <summary>
  58.     /// 获取信息
  59.     /// </summary>
  60.     public void MyDataBind(int idex)
  61.     {
  62.         AspNetPager1.RecordCount = BUP.GetCount("");
  63.         List<Model.ASPClass> LRData = BUP.GetPageList(10,idex,"ID",true,"");
  64.         if (LRData.Count == 0)
  65.         {
  66.             Model.ASPClass MR = new Model.ASPClass();
  67.             LRData.Add(MR);
  68.         }
  69.         GridView1.DataSource = LRData;
  70.         GridView1.DataBind();
  71.     }
  72.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  73.     {
  74.         for (int i = 0; i < GridView1.Rows.Count; i++)
  75.         {
  76.             //首先判断是否是数据行
  77.             if (e.Row.RowType == DataControlRowType.DataRow)
  78.             {
  79.                 //当鼠标停留时更改背景色
  80.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  81.                 //当鼠标移开时还原背景色
  82.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  83.                 string GRCTTS=GridView1.Rows[i].Cells[3].Text.ToString();
  84.                 if (IsHaveExcept(GRCTTS))
  85.                 {
  86.                     CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  87.                     cbox.Checked = false;
  88.                 }
  89.             }
  90.           
  91.        
  92.       
  93.         }
  94.     }
  95.     protected void DelButton1_Click(object sender, EventArgs e)
  96.     {
  97.         try
  98.         {
  99.             MyMUP = MyBUP.GetModel(int.Parse(Request.QueryString["id"].ToString()));
  100.             string UpdatePrives = MyMUP.FuncIdStr;
  101.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  102.             {
  103.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  104.                 if (cbox.Checked)
  105.                 {
  106.                     // Response.Write(GridView1.Rows[i].Cells[1].Text.ToString() + ":True");
  107.                     string classname = GridView1.Rows[i].Cells[3].Text.ToString();
  108.                 UpdatePrives=    UpdatePrives.Replace(classname + ",","");
  109.           
  110.                 }
  111.                 else
  112.                 {
  113.                     string  classname = GridView1.Rows[i].Cells[3].Text.ToString();
  114.                    UpdatePrives= UpdatePrives.Replace(classname + ",", "");
  115.                     UpdatePrives += classname + ",";
  116.                 }
  117.             }
  118.         
  119.               MyMUP.FuncIdStr=UpdatePrives;
  120.               MyBUP.Update(MyMUP);
  121.             MessageBox.Show("保存完毕!");
  122.         }
  123.         catch (Exception exp)
  124.         { MessageBox.Show(exp.Message); }
  125.     }
  126.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  127.     {
  128.         MyDataBind(e.NewPageIndex);
  129.     }
  130.     protected void AspNetPager1_PageChanged(object sender, EventArgs e)
  131.     {
  132.  
  133.     }
  134. }