OpRoleModify.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:5k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  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 com.etong.DAL.FC;
  12. public partial class SysManage_OpRoleModify : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             Response.Buffer = true;
  19.             Response.ExpiresAbsolute = System.DateTime.Now;
  20.             Response.Expires = 0;
  21.             Response.CacheControl = "no-cache";
  22.             EtongFlyChouWFPrj EFlyPrj = new EtongFlyChouWFPrj();
  23.             DataView dv = EFlyPrj.GetOpPermAll();
  24.             ChList.DataTextField = "DisplayName";
  25.             ChList.DataValueField = "PermID";
  26.             ChList.DataSource = dv;
  27.             ChList.DataBind();
  28.             //新添加
  29.             EtongWord EWord = new EtongWord();
  30.             dv = EWord.GetAllFName();
  31.             ChFName.DataTextField = "FName";
  32.             ChFName.DataValueField = "FID";
  33.             ChFName.DataSource = dv;
  34.             ChFName.DataBind();
  35.             //新新添加
  36.             EtongFlyChou EFly = new EtongFlyChou();
  37.             dv = EFly.GetEmpType();
  38.             DLstSort.DataTextField = "name";
  39.             DLstSort.DataValueField = "id";
  40.             DLstSort.DataSource = dv;
  41.             DLstSort.DataBind();
  42.  
  43.             if (Request.QueryString["strN"].Trim() == "M")
  44.             {
  45.                 int iOp;
  46.                 try
  47.                 {
  48.                     iOp = Convert.ToInt32(Request.QueryString["strOp"].Trim());
  49.                 }
  50.                 catch
  51.                 {
  52.                     iOp = 1;
  53.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.close()", true);
  54.                     return;
  55.                 }
  56.                 EFlyPrj.OpID = iOp;
  57.                 dv = EFlyPrj.GetOpRoleByOp();
  58.                 DataView dv2 = EFlyPrj.GetOpPerm();
  59.                 if (dv.Table.Rows.Count > 0)
  60.                 {
  61.                     TID.Text = dv.Table.Rows[0]["OpName"].ToString();
  62.                     //新新修改
  63.                     //TDesc.Text = dv.Table.Rows[0]["OrgDesc"].ToString();
  64.                     DLstSort.Items.FindByValue(DLstSort.SelectedValue).Selected = false;
  65.                     DLstSort.Items.FindByValue(dv.Table.Rows[0]["OrgDesc"].ToString()).Selected = true;
  66.                 }
  67.                 for (int i = 0; i < dv2.Table.Rows.Count; i++)
  68.                 {
  69.                     for (int j = 0; j < ChList.Items.Count; j++)
  70.                     {
  71.                         if (dv2.Table.Rows[i][0].ToString().Trim() == ChList.Items[j].Value.ToString().Trim()) ChList.Items[j].Selected = true;
  72.                     }
  73.                 }
  74.                 //新添加
  75.                 EWord.Role = iOp;
  76.                 dv = EWord.GetRoleFNameByCondition();
  77.                 for (int k = 0; k < dv.Table.Rows.Count; k++)
  78.                 {
  79.                     ChFName.Items[k].Selected = dv.Table.Rows[k][0].ToString().Trim() == ChFName.Items[k].Value.ToString().Trim() ? true:false;
  80.                 }
  81.             }
  82.         }
  83.     }
  84.     protected void ImgSave_Click(object sender, ImageClickEventArgs e)
  85.     {
  86.         int iOp;
  87.         try
  88.         {
  89.             iOp = Convert.ToInt32(Request.QueryString["strOp"].Trim());
  90.         }
  91.         catch
  92.         {
  93.             iOp = 1;
  94.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.close()", true);
  95.             return;
  96.         }
  97.         EtongFlyChouWFPrj EFlyPrj = new EtongFlyChouWFPrj();
  98.         EFlyPrj.OpID = iOp;
  99.         EFlyPrj.OpName = TID.Text.Trim();
  100.         //新新修改
  101.         //EFlyPrj.OpDesc = TDesc.Text.Trim();
  102.         EFlyPrj.OpDesc = DLstSort.SelectedValue.ToString();
  103.         ArrayList al = new ArrayList();
  104.         for (int i = 0; i < ChList.Items.Count; i++)
  105.         {
  106.             if (ChList.Items[i].Selected == true) al.Add(ChList.Items[i].Value);
  107.         }
  108.         EFlyPrj.OpPerm = al;
  109.         try
  110.         {
  111.             EFlyPrj.UpOpPerm();
  112.         }
  113.         catch (Exception ex)
  114.         {
  115.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  116.             return;
  117.         }
  118.         ArrayList alf = new ArrayList();
  119.         for (int k = 0; k < ChFName.Items.Count; k++)
  120.         {
  121.             if (ChFName.Items[k].Selected == true) alf.Add(ChFName.Items[k].Value);
  122.         }
  123.         EtongWord EWord = new EtongWord();
  124.         try
  125.         {
  126.             EWord.Role = iOp;
  127.             EWord.AFID = alf;
  128.             EWord.RUpdate();
  129.         }
  130.         catch (Exception ex)
  131.         {
  132.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  133.             return;
  134.         }
  135.         this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:保存成功!');window.close();", true);
  136.     }
  137. }