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.
DS7/DSWeb/Authority/UserAuthorityRangeSet.aspx.cs

193 lines
8.1 KiB
C#

2 years 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.ParameterSet
{
public partial class UserAuthorityRangeSet : 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()));
}
}
}
}
//
getList();
}
}
protected void getList()
{
DataSet DS = T_ALL_DA.GetAllSQL("select *,VISIBLERANGE2=5,OPERATERANGE2=5,GID as AUTHORITYID from User_Authority_Info where ISDELETE=0 ORDER BY DESCRIPTION");
if (DS != null)
{
if (DS.Tables[0].Rows.Count != 0)
{
dllist.DataSource = DS;
dllist.DataBind();
}
}
}
protected void btnEnter_Click(object sender, ImageClickEventArgs e)
{
if (ListBox1.SelectedValue.ToString().Trim().Equals(""))
{
Response.Write("<script>alert('请先选择要设置权限的用户!');</script>");
return;
}
else
{
string alt = "";
for (int i = 0; i < dllist.Items.Count; i++)
{
string AUTHORITYID = this.dllist.DataKeys[i].ToString();
if (AUTHORITYID != "")
{
string VISIBLERANGE = ((RadioButtonList)this.dllist.Items[i].FindControl("RadioButtonList1")).SelectedValue.ToString();
string OPERATERANGE = ((RadioButtonList)this.dllist.Items[i].FindControl("RadioButtonList2")).SelectedValue.ToString();
if (VISIBLERANGE == "")
{
VISIBLERANGE = "5";
}
if (OPERATERANGE == "")
{
OPERATERANGE = "5";
}
if (int.Parse(OPERATERANGE.Trim()) < int.Parse(VISIBLERANGE.Trim()))
{
OPERATERANGE = VISIBLERANGE;
}
alt = T_ALL_DA.GetStrSQL("GID", "select GID from user_authority_range where USERID='" + ListBox1.SelectedValue.ToString().Trim() + "' and AUTHORITYID='" + AUTHORITYID + "'");
if (alt == "")
{
alt = T_ALL_DA.GetUserAuthorityRangeInsert(ListBox1.SelectedValue.ToString().Trim(), AUTHORITYID, VISIBLERANGE, OPERATERANGE, strUserID.Trim());
}
else
{
alt = T_ALL_DA.GetUserAuthorityRangeUpdate(ListBox1.SelectedValue.ToString().Trim(), AUTHORITYID, VISIBLERANGE, OPERATERANGE, strUserID.Trim());
}
}
}
//
if (alt == "")
{
getuserlist();
Response.Write("<script>alert('成功提交!');</script>");
return;
}
else
{
Response.Write("<script>alert('" + alt + "');history.back();</script>");
return;
}
}
}
protected void getuserlist()
{
DataSet DS = T_ALL_DA.GetAllSQL("select *, ISNULL(VISIBLERANGE, 5) AS VISIBLERANGE2,ISNULL(OPERATERANGE, 5) AS OPERATERANGE2 from user_authority_info a LEFT JOIN (select * from user_authority_range where USERID='" + ListBox1.SelectedValue.ToString().Trim() + "') b ON a.GID = b.AUTHORITYID where a.ISDELETE=0 ORDER BY a.DESCRIPTION");
if (DS != null)
{
if (DS.Tables[0].Rows.Count != 0)
{
dllist.DataSource = DS;
dllist.DataBind();
}
else
{
getList();
}
}
else
{
getList();
}
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
getuserlist();
}
protected void dllist_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
{
string AUTHORITYID = this.dllist.DataKeys[e.Item.ItemIndex].ToString();
DataSet DS = T_ALL_DA.GetAllSQL("select *,VISIBLERANGE2=5,OPERATERANGE2=5,GID as AUTHORITYID from User_Authority_Info where ISDELETE=0 and GID='"+AUTHORITYID+"'");
if (DS != null)
{
if(DS.Tables[0].Rows.Count>0)
{
if(DS.Tables[0].Rows[0]["ISALL"].ToString().Trim().Equals("True"))
{
((RadioButtonList)e.Item.FindControl("RadioButtonList1")).Items[0].Enabled = false;
((RadioButtonList)e.Item.FindControl("RadioButtonList2")).Items[0].Enabled = false;
}
if (DS.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
((RadioButtonList)e.Item.FindControl("RadioButtonList1")).Items[1].Enabled = false;
((RadioButtonList)e.Item.FindControl("RadioButtonList2")).Items[1].Enabled = false;
}
if (DS.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
((RadioButtonList)e.Item.FindControl("RadioButtonList1")).Items[2].Enabled = false;
((RadioButtonList)e.Item.FindControl("RadioButtonList2")).Items[2].Enabled = false;
}
if (DS.Tables[0].Rows[0]["ISPERSON"].ToString().Trim().Equals("True"))
{
((RadioButtonList)e.Item.FindControl("RadioButtonList1")).Items[3].Enabled = false;
((RadioButtonList)e.Item.FindControl("RadioButtonList2")).Items[3].Enabled = false;
}
}
}
}
}
}
}