人法地,地法天,天法道,道法自然
分类:
2009-10-15 23:10:08
存储过程代码:
已分配权限:
DELIMITER $$ DROP PROCEDURE IF EXISTS `studb`.`user_menu_ye_p` $$ CREATE PROCEDURE `studb`.`user_menu_ye_p` (in idus varchar(10)) BEGIN select userpop.id,userpop.idmen,umenu.idmet,umenu.sname,ument.tname,umenu.path,userpop.whofp,userpop.datefp from userpop inner join umenu on userpop.idmen=umenu.idmen inner join ument on umenu.idmet=ument.idmet where userpop.iduse=idus; END $$ DELIMITER ; |
可分配权限:
DELIMITER $$ DROP PROCEDURE IF EXISTS `studb`.`user_menu_no_p` $$ CREATE PROCEDURE `studb`.`user_menu_no_p` (in idus varchar(10),in poptype varchar(1)) BEGIN select umenu.idmen,umenu.idmet,umenu.sname,ument.tname from umenu inner join ument on umenu.idmet=ument.idmet where umenu.idmen not in (select idmen from userpop where iduse=idus and pop_type=poptype); END $$ DELIMITER ; |
程序代码:
protected void isexistpopup(string iduse) //已存在菜单权限 { myco = new MySqlConnection(strconn); myco.Open(); mycomm = new MySqlCommand("user_menu_ye_p", myco); mycomm.CommandType = CommandType.StoredProcedure; mycomm.Parameters.Add("@idus", iduse); MySqlDataAdapter myAdapter = new MySqlDataAdapter(mycomm); DataSet myDataSet = new DataSet(); DataView m_DataView = new DataView(); myAdapter.Fill(myDataSet); m_DataView = myDataSet.Tables[0].DefaultView; GridView4.DataSource = m_DataView; GridView4.DataBind(); myco.Close(); } protected void noexistpopup(string iduse) //尚未分配的权限 { myco = new MySqlConnection(strconn); myco.Open(); mycomm = new MySqlCommand("user_menu_no_p", myco); mycomm.CommandType = CommandType.StoredProcedure; mycomm.Parameters.Add("@idus", iduse); mycomm.Parameters.Add("@poptype", "M"); MySqlDataAdapter myAdapter = new MySqlDataAdapter(mycomm); DataSet myDataSet = new DataSet(); DataView m_DataView = new DataView(); myAdapter.Fill(myDataSet); m_DataView = myDataSet.Tables[0].DefaultView; GridView5.DataSource = m_DataView; GridView5.DataBind(); myco.Close(); } |