2024-05-18 15:28:29 +08:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Web ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
using System.Data ;
using System.Data.SqlClient ;
using Ajax ;
public partial class Jurisdiction : CommonPage
{
//创建一个共用的角色bll
Maticsoft . BLL . nr_z_yhjs juesebll = new Maticsoft . BLL . nr_z_yhjs ( ) ;
//创建一个操作记录模板
Maticsoft . Model . nr_sys_rizhi rizhi = new Maticsoft . Model . nr_sys_rizhi ( ) ;
//创建一个操作记录bll
2024-05-21 15:05:24 +08:00
Maticsoft . BLL . nr_sys_rizhi rizhibll = new Maticsoft . BLL . nr_sys_rizhi ( ) ;
2024-05-18 15:28:29 +08:00
Maticsoft . Model . nr_z_yhjs jsmd = new Maticsoft . Model . nr_z_yhjs ( ) ;
protected void Page_Load ( object sender , EventArgs e )
{
Utility . RegisterTypeForAjax ( typeof ( Jurisdiction ) ) ;
if ( ! IsPostBack )
{
if ( Session [ "user" ] = = null )
{
Response . Redirect ( "../index.aspx" ) ;
}
//获取角色权限
Maticsoft . Model . nr_z_yhzh user = ( Maticsoft . Model . nr_z_yhzh ) ( Session [ "user" ] ) ;
2024-05-21 15:05:24 +08:00
pdquanxian ( user . juese ) ;
2024-05-18 15:28:29 +08:00
getbdjs ( ) ;
}
}
public void getbdjs ( )
2024-05-21 15:05:24 +08:00
{
2024-05-18 15:28:29 +08:00
DataSet xz = juesebll . GetAllList ( ) ;
if ( xz ! = null )
{
xzjs . DataSource = xz . Tables [ 0 ] . DefaultView ;
xzjs . DataValueField = "id" ;
xzjs . DataTextField = "mingcheng" ;
xzjs . DataBind ( ) ;
jsidz . Text = xz . Tables [ 0 ] . Rows [ 0 ] [ "id" ] . ToString ( ) ;
jsid . Value = xz . Tables [ 0 ] . Rows [ 0 ] [ "id" ] . ToString ( ) ;
2024-05-21 15:05:24 +08:00
string yhsl = DBHlper . getfirstcolmn ( "select count(*) from nr_z_yhzh where juese='" + xz . Tables [ 0 ] . Rows [ 0 ] [ "id" ] + "'" ) ;
jsyhsl . Text = yhsl + "个" ;
2024-05-18 15:28:29 +08:00
}
drp_mk . DataSource = DBHlper . Execute ( "select id,mc from nr_sys_mkarear where isview=1 ORDER BY xh" ) . Tables [ 0 ] ;
drp_mk . DataTextField = "mc" ;
drp_mk . DataValueField = "mc" ;
2024-05-21 15:05:24 +08:00
drp_mk . DataBind ( ) ;
2024-05-18 15:28:29 +08:00
}
[Ajax.AjaxMethod]
public string quanxianlist ( string mkname , string jsid )
{
string jueseming = juesebll . GetModel ( Convert . ToInt32 ( jsid ) ) . mingcheng ;
string htmlcode = "<table id='tbl_list' width='100%' class='tablewk'>"
+ "<tr><td td width='58px' style='border-right: 0px; border-left: 0px;'></td><td colspan='3' style='height:30px;border-right: 0px;color:red; border-left: 0px;'>"
+ "您正在为角色   [   " + jueseming + "   ]  设置权限        全选:   <input type='checkbox' id='qxan' onclick='selectAll(this)' /> </td></tr>" ;
string cmd = "select mc from dbo.nr_sys_mk where isview=1 and belongmkid in(select id from dbo.nr_sys_mkarear where isview=1 and mc like '%" + mkname + "%')" ;
2024-05-21 15:05:24 +08:00
DataTable mokanlist = DBHlper . Execute ( cmd ) . Tables [ 0 ] ;
2024-05-18 15:28:29 +08:00
if ( mkname = = "财务管理" | | mkname = = "" )
{
mokanlist . Rows . Remove ( mokanlist . Select ( "mc='订单待收款'" ) [ 0 ] ) ;
mokanlist . Rows . Remove ( mokanlist . Select ( "mc='外协待付款'" ) [ 0 ] ) ;
mokanlist . Rows . Remove ( mokanlist . Select ( "mc='供应商待付款'" ) [ 0 ] ) ;
mokanlist . Rows . Remove ( mokanlist . Select ( "mc='客户期初欠款'" ) [ 0 ] ) ;
for ( int i = 0 ; i < mokanlist . Rows . Count ; i + + )
{
if ( mokanlist . Rows [ i ] [ "mc" ] . ToString ( ) = = "订单收款确认" )
{
mokanlist . Rows [ i ] [ "mc" ] = "订单收款" ;
}
else if ( mokanlist . Rows [ i ] [ "mc" ] . ToString ( ) = = "外协付款确认" )
{
mokanlist . Rows [ i ] [ "mc" ] = "外协付款" ;
}
else if ( mokanlist . Rows [ i ] [ "mc" ] . ToString ( ) = = "供应商付款确认" )
{
mokanlist . Rows [ i ] [ "mc" ] = "供应商付款" ;
}
}
}
string selectquanxian = "select gnid from nr_z_quanxian where jsid=" + jsid ;
DataTable quanxianidtable = DBHlper . Execute ( selectquanxian ) . Tables [ 0 ] ;
string mkmc = "" ;
foreach ( DataRow dtr in mokanlist . Rows )
{
mkmc = dtr [ 0 ] . ToString ( ) ;
string selectduiying = "" ;
DataTable dtall = new DataTable ( ) ;
selectduiying = "select id,gongneng from nr_sys_gn where mokuan like '%" + dtr [ "mc" ] + "%' ORDER by xuhao " ;
dtall = DBHlper . Execute ( selectduiying ) . Tables [ 0 ] ;
htmlcode + = "<tr><td></td><td>" + dtr [ 0 ] + "</td><td width='58'>全选 <input type='checkbox' onclick='qxmkselectall(this)' /></td><td><ul class='ul_mk'>" ;
foreach ( DataRow dr in dtall . Rows )
{
DataRow [ ] dtrow = quanxianidtable . Select ( "gnid=" + dr [ "id" ] ) ;
if ( dtrow . Length > 0 )
{
htmlcode + = "<li><input type='checkbox' checked tag=" + dr [ "id" ] + " id=mk_" + dr [ "id" ] + " /><label for='mk_" + dr [ "id" ] + "'>" + dr [ "gongneng" ] + "</label></li>" ;
}
else
{
htmlcode + = "<li><input type='checkbox' tag=" + dr [ "id" ] + " id=mk_" + dr [ "id" ] + " /><label for='mk_" + dr [ "id" ] + "'>" + dr [ "gongneng" ] + "</label></li>" ;
}
}
htmlcode + = "</ul></td></tr>" ;
}
htmlcode + = "</table>" ;
return htmlcode ;
}
#region 权 限 添 加
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public void savequanxian ( string jsid , string qxid , string mkmc )
{
DBHlper . excutecmd ( "delete from nr_z_quanxian where jsid=" + jsid + " and gnid in(select id from dbo.nr_sys_gn where mokuan in(select mc from dbo.nr_sys_mk where belongmkid in (select id from nr_sys_mkarear where mc like '%" + mkmc + "%')))" ) ;
if ( mkmc = = "财务管理" )
{
DBHlper . excutecmd ( "delete from nr_z_quanxian where jsid=" + jsid + " and gnid in(select id from dbo.nr_sys_gn where mokuan='订单收款' or mokuan='外协付款' or mokuan='供应商付款')" ) ;
}
if ( qxid ! = "" )
{
string [ ] quanxianid = qxid . Trim ( ',' ) . Split ( ',' ) ;
foreach ( string id in quanxianid )
{
string updatecmd = string . Format ( "insert into nr_z_quanxian values({0},{1})" , jsid , id ) ;
DBHlper . excutecmd ( updatecmd ) ;
}
}
//给日志模板赋值
rizhi . riqi = DateTime . Now ;
rizhi . leixing = "系统角色" ;
//将session转换对象取值
Maticsoft . Model . nr_z_yhzh zh = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
rizhi . yonghuming = zh . zhanghao ;
//拼接字符串插入日志
rizhi . jilu = zh . zhanghao + "为角色授权,角色名为:" + juesebll . GetModel ( Convert . ToInt32 ( jsid ) ) . mingcheng ; ;
rizhibll . Add ( rizhi ) ;
}
#endregion
#region 敏 感 权 限 查 看
void pdquanxian ( int juese )
{
Maticsoft . Model . nr_z_yhzh user = ( Maticsoft . Model . nr_z_yhzh ) ( Session [ "user" ] ) ;
if ( DBHlper . getzt ( user . id ) ! = 1 )
{
Response . Redirect ( "../index.aspx" ) ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "系统角色" , "nr_z_yhjs" , "角色授权" ) = = false )
2024-05-18 15:28:29 +08:00
{
Response . Redirect ( "../Common/nopower.htm" ) ;
}
}
#endregion
#region 查 询 角 色 名 称 是 否 重 复
[Ajax.AjaxMethod]
public int serchmingcheng ( string str )
{
string cmd = string . Format ( "select * from nr_z_yhjs where mingcheng='{0}'" , str . Replace ( " " , "" ) ) ;
int count = DBHlper . getcount ( cmd ) ;
return count ;
}
#endregion
protected void bt_tj_Click ( object sender , EventArgs e )
{
if ( getjs . PanDing )
{
if ( DBHlper . getjscount ( ) > = getjs . JsCount )
{
z_error . Text = "请您购买足够的角色!" ;
return ;
}
}
jsmd . mingcheng = jsmc . Value . Trim ( ) ;
int s = juesebll . Add ( jsmd ) ;
if ( s > 0 )
{
//给日志模板赋值
rizhi . riqi = DateTime . Now ;
rizhi . leixing = "系统角色" ;
//将session转换对象取值
Maticsoft . Model . nr_z_yhzh zh = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
rizhi . yonghuming = zh . zhanghao ;
//拼接字符串插入日志
rizhi . jilu = zh . zhanghao + "添加了系统角色,角色名为:" + jsmc . Value . Trim ( ) ;
rizhibll . Add ( rizhi ) ;
Response . Write ( "<script>alert('角色添加成功'); window.location.href = 'Jurisdiction.aspx';</script>" ) ;
}
}
protected void xzjs_SelectedIndexChanged ( object sender , EventArgs e )
{
2024-05-21 15:05:24 +08:00
string yhsl = DBHlper . getfirstcolmn ( "select count(*) from nr_z_yhzh where juese='" + xzjs . SelectedValue + "'" ) ;
2024-05-18 15:28:29 +08:00
jsidz . Text = xzjs . SelectedValue ;
jsid . Value = xzjs . SelectedValue ;
jsyhsl . Text = yhsl + "个" ;
}
protected void scjs_Click ( object sender , EventArgs e )
{
2024-05-21 15:05:24 +08:00
string cmdcjs = "select * from nr_z_yhzh where juese='" + jsid . Value + "'" ;
DataSet ds = DBHlper . Execute ( cmdcjs ) ;
if ( ds ! = null & & ds . Tables [ 0 ] . Rows . Count > 0 )
{
z_error . Text = "该角色下存在用户删除失败!" ;
return ;
}
else
{
string cmdsjs = "delete nr_z_yhjs where id='" + jsid . Value + "'" ;
if ( DBHlper . excutecmd ( cmdsjs ) > 0 )
{
//给日志模板赋值
rizhi . riqi = DateTime . Now ;
rizhi . leixing = "系统角色" ;
//将session转换对象取值
Maticsoft . Model . nr_z_yhzh zh = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
rizhi . yonghuming = zh . zhanghao ;
//拼接字符串插入日志
rizhi . jilu = zh . zhanghao + "删除了系统角色,角色名为:" + xzjs . Text . Trim ( ) ;
rizhibll . Add ( rizhi ) ;
Response . Write ( "<script>alert('角色删除成功'); window.location.href = 'Jurisdiction.aspx';</script>" ) ;
}
}
2024-05-18 15:28:29 +08:00
}
}