You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
7.8 KiB
C#

12 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Web.Script.Serialization;
namespace DSWeb.Authority
{
public partial class UserAuthority : System.Web.UI.Page
{
public string sSQL = String.Empty;
TopSeaeBillmanageEntity TopSeaeBillmanageEntity = new TopSeaeBillmanageEntity();
TopSeaeBillmanageDA TopSeaeBillmanageDA = new TopSeaeBillmanageDA();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
public string strUserID;//用户GID
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
//strUserID = "";
}
//
if (!IsPostBack)
{
UserDA UserDA = new UserDA();
DataSet ds = UserDA.GetUserSQL(" and ISDISABLE=0 and ISDELETED=0");
if (ds != null)
{
if (!ds.Tables[0].Rows[0]["GID"].ToString().Trim().Equals(""))
{
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
ListBox1.Items.Add(new ListItem(myRow["CODENAME"].ToString().Trim()+" | "+myRow["SHOWNAME"].ToString().Trim(), myRow["GID"].ToString().Trim()));
}
}
}
}
//
ds = T_ALL_DA.GetActionSQL(" ORDER BY DESCRIPTION ASC ");
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
ListBox2.Items.Add(new ListItem(myRow["DESCRIPTION"].ToString().Trim(), myRow["GID"].ToString().Trim()));
}
}
}
}
protected void btnEnter_Click(object sender, ImageClickEventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("<script>alert('请先选择要设置权限的用户!');</script>");
return;
}
else
{
string alt = "";
alt = T_ALL_DA.GetUserActionDel(ListBox1.SelectedValue.ToString().Trim(), strUserID.Trim());
if (alt == "")
{
if (ListBox3.Items.Count > 0)
{
for (int i=0; i< ListBox3.Items.Count;i++)
{
alt = T_ALL_DA.GetUserActionInsert( ListBox1.SelectedValue.ToString().Trim(),ListBox3.Items[i].Value.ToString().Trim(), strUserID.Trim());
if (alt != "")
{
Response.Write("<script>alert('" + alt + "');history.back();</script>");
return;
}
}
}
else
{
Response.Write("<script>alert('成功提交!');</script>");
return;
}
}
else
{
Response.Write("<script>alert('"+alt+"');history.back();</script>");
return;
}
Response.Write("<script>alert('成功提交!');</script>");
return;
}
}
protected void Button1_Click(object sender, System.EventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("<script>alert('请先选择要设置权限的用户!');</script>");
return;
}
for (int i = 0; i < ListBox2.Items.Count; i++)
{
ListBox3.Items.Add(new ListItem(ListBox2.Items[i].Text.Trim(), ListBox2.Items[i].Value.Trim()));
}
ListBox2.Items.Clear();
}
protected void Button2_Click(object sender, System.EventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("<script>alert('请先选择要设置权限的用户!');</script>");
return;
}
for(var i=0;i<ListBox2.Items.Count;i++)
{
if(ListBox2.Items[i].Selected)
{
ListBox3.Items.Add(new ListItem(ListBox2.Items[i].Text.Trim(), ListBox2.Items[i].Value.Trim()));
ListBox2.Items.Remove(ListBox2.Items[i]);
i = i - 1;
}
}
}
protected void Button4_Click(object sender, System.EventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("<script>alert('请先选择要设置权限的用户!');</script>");
return;
}
for (var i = 0; i < ListBox3.Items.Count; i++)
{
if (ListBox3.Items[i].Selected)
{
ListBox2.Items.Add(new ListItem(ListBox3.Items[i].Text.Trim(), ListBox3.Items[i].Value.Trim()));
ListBox3.Items.Remove(ListBox3.Items[i]);
i = i - 1;
}
}
}
protected void Button3_Click(object sender, System.EventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("<script>alert('请先选择要设置权限的用户!');</script>");
return;
}
for (int i = 0; i < ListBox3.Items.Count; i++)
{
ListBox2.Items.Add(new ListItem(ListBox3.Items[i].Text.Trim(), ListBox3.Items[i].Value.Trim()));
}
ListBox3.Items.Clear();
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ListBox2.Items.Clear();
ListBox3.Items.Clear();
DataSet ds = T_ALL_DA.GetActionSQL(" and GID not in (select ACTIONID from user_action where USERID='" + ListBox1.SelectedValue.ToString().Trim() + "') ORDER BY DESCRIPTION ASC ");
if (ds != null)
{
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
ListBox2.Items.Add(new ListItem(myRow["DESCRIPTION"].ToString().Trim(), myRow["GID"].ToString().Trim()));
}
}
}
//
ds = T_ALL_DA.GetActionSQL(" and GID in (select ACTIONID from user_action where USERID='" + ListBox1.SelectedValue.ToString().Trim() + "') ORDER BY DESCRIPTION ASC ");
if (ds != null)
{
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
ListBox3.Items.Add(new ListItem(myRow["DESCRIPTION"].ToString().Trim(), myRow["GID"].ToString().Trim()));
}
}
}
}
}
}