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("");
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("");
return;
}
}
}
else
{
Response.Write("");
return;
}
}
else
{
Response.Write("");
return;
}
Response.Write("");
return;
}
}
protected void Button1_Click(object sender, System.EventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("");
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("");
return;
}
for(var i=0;ialert('请先选择要设置权限的用户!');");
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("");
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()));
}
}
}
}
}
}