Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > asp技巧

用asp实现分级权限控制

来源:中文源码网    浏览:371 次    日期:2024-05-08 21:13:47
【下载文档:  用asp实现分级权限控制.txt 】


用ASP实现分级权限控制
用ASP实现分级权限控制   本文实现的是一个帐务管理系统中分级权限的控制,程序使用ASP和javascript编写,在装有IIS4.0的win NT服务器上运行,速度快,易维护。权限级别划分如下:①、院长和财务科长:不能输入,可以无限制查询、统计;②、副院长:不能输入,可以查询、统计其分管部门的帐务;③、部门领导:不能输入,可以查询、统计本部门的帐务;④、会计:能输入各部门的帐务(一个会计有时要做几个部门的帐),只能查询、统计自己输入的帐务。涉及的数据库和字段如下①、JK_USER数据库及字段:id(序列号),bmid(部门号),username(用户名),pwd(口令),right(权限值);②、BM数据库及字段:id(序列号) ,bmid(部门号);③、JZPZ数据库及字段:id(序列号),bm(部门), zgs(子公司),xmz(项目组),xm(项目),sr(收入),zc(支出),szfx(收支方向),szxs(收支形式),rq(日期),jbr(经办人),lrr(录入人),szsm(收支说明); ④、ZGS数据库及字段:id(序列号),zgs(子公司)name(公司名),bmid(部门编号)。1.首先进行用户身份合法性验证  将用户提交的用户名和口令与数据库JK_USER中的字段对照对照,以确定其合法性,只有合法的用户(系统管理员为其开过户)才可以进入,合法用户有四种权限级别,分别赋予“1”、“2”、“3”、“4”四种权限值。(程序略)。2.凭证记帐(分级权限控制)  凭证记帐功能是专为会计人员服务的,其他人不可以使用,如以非会计人员身份进入凭证录入界面时,只有“查询记帐凭证”功能按钮可见,其它功能按钮不可见。录入的凭证先存放在一个临时表里,称为“未记帐凭证库”,只有运行“凭证记帐”功能后才进入“凭证库”在“未记帐凭证库”中的凭证可以修改。部分程序如下:'非会计人员进入,不显示“凭证记帐”和“保存未记帐凭证”功能按钮if (thisPage.firstEntered) then if session("tright")<> "1" then button1.hidebutton2.hideend if…………'自动填写时间和操作人Textbox7.value=year(date) & "-" & month(date) & "-" & day(date)Textbox9.value =session("username") set cnn1=server.CreateObject("adodb.connection")set rst1=server.CreateObject("adodb.recordset")cnn1.CursorLocation=3cnn1.ConnectionTimeout =30cnn1.Open "DSN=jky"rst1.Open "select * from bm ",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenRST1.MoveFirst Id=rst1.Fields("id")do while not rst1.EOFListbox3.addItem rst1.Fields("bmName"),cint(rst1.Fields("id"))“Response.Write rst1.Fields("bmname") & rst1.Fields("id")rst1.MoveNext loopend ifrst1.Closerst1.Open "select zgsname from zgs where bmid=" & id,cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenrst1.MoveFirst do while not rst1.EOFListbox4.addItem cstr(rst1.Fields("zgsname"))rst1.MoveNext loopend ifrst1.Closecnn1.closecall writerstend ifend function………………'凭证记帐sub button2_onclickdim ss=Listbox1.selectedIndexResponse.Write send subsub listbox3_onchangedim id,ii=Listbox4.getCount()do while i>-1call Listbox4.removeItem(i)i=i-1loopid=listbox3.getValue (listbox3.selectedIndex)set cnn2=server.CreateObject("adodb.connection")set rst2=server.CreateObject("adodb.recordset")cnn2.CursorLocation=3cnn2.ConnectionTimeout =30cnn2.Open"DSN=jky"rst2.Open "select zgsName from zgs where bmid=" & id,cnn2,1,1,adcmdtextif rst2.RecordCount >0 thenRST2.MoveFirst do while not rst2.EOFListbox4.addItem cstr(rst2.Fields("zgsName"))rst2.MoveNext loopend ifrst2.Closecnn2.Closeend subsub button2_onclickset cnn5=server.CreateObject("adodb.connection")cnn5.CursorLocation=3cnn5.ConnectionTimeout =30cnn5.Open"DSN=jky"cnn5.Execute "insert into jzpz(bm,zgs,xmz,xm,sr,zc,szfx,szxs,rq,jbr,lrr,szsm) select bm,zgs,xmz,xm,sr,zc,szfx,szxs,rq,jbr,lrr,szsm from wjzpz where lrr=“" & session("username") & "“"cnn5.Execute "delete from wjzpz where lrr=“" & session("username") & "“"end sub3.数据查询(分级权限控制)以凭证的字段为条件进行查询,在供选条件前有一方框供打“√”,其中“部门“条件必选(程序自动加上),部门内容由程序根据用户的权限自动从数据库中调用相应值,分公司内容根据所属部门自动调整,部分程序如下:……………'根据权限值进入相应的查询界面……………function thisPage_onenter()set cnn1=server.CreateObject("adodb.connection")set rst1=server.CreateObject("adodb.recordset")cnn1.CursorLocation=3cnn1.ConnectionTimeout =30cnn1.Open "dsn=jky"select case session("Tright")case "3"“副院长rst1.Open "select bm.bmName from jk_user ,bm where JK_user.bmid=bm.id and jk_user.username =“"& session("username") & "“",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenRST1.MoveFirst do while not rst1.EOFListbox1.addItem cstr(rst1.Fields("bmName"))rst1.MoveNext loopend ifrst1.Closerst1.Open "select zgsname from zgs ",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenrst1.MoveFirst do while not rst1.EOFListbox2.addItem cstr(rst1.Fields("zgsname"))rst1.MoveNext loopend ifrst1.Closecnn1.closeCheckbox1.setChecked (true)case "2"“部门经理Listbox1.addItem session("bm")rst1.Open "select zgsname from zgs where bmid=" & session("bmid"),cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenrst1.MoveFirst do while not rst1.EOFListbox2.addItem cstr(rst1.Fields("zgsname"))rst1.MoveNext loopend ifrst1.Closecnn1.closeCheckbox1.setChecked (true)“Checkbox1.0 case "1"“会计 rst1.Open "select bmName from bm ",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenRST1.MoveFirst do while not rst1.EOFListbox1.addItem cstr(rst1.Fields("bmName"))rst1.MoveNext loopend ifrst1.Closerst1.Open "select zgsname from zgs ",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenrst1.MoveFirst do while not rst1.EOFListbox2.addItem cstr(rst1.Fields("zgsname"))rst1.MoveNext loopend ifrst1.Closecnn1.closecase "4"“院长 rst1.Open "select bmName from bm ",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenRST1.MoveFirst do while not rst1.EOFListbox1.addItem cstr(rst1.Fields("bmName"))rst1.MoveNext loopend ifrst1.Closerst1.Open "select zgsname from zgs ",cnn1,1,1,adcmdtextif rst1.RecordCount >0 thenrst1.MoveFirst do while not rst1.EOFListbox2.addItem cstr(rst1.Fields("zgsname"))rst1.MoveNext loopend ifrst1.Closecnn1.closeend select end if…………end function'按照权限查询凭证sub button1_onclickdim rst2,cnn2,str,idim bm(1),zgs(1),xmz(1),xm(1),szfx(1),szxs(1),rq(2),jbr(1)bm(0)=Checkbox1.getChecked()if bm(0) thenbm(1)=Listbox1.getText(Listbox1.selectedIndex )str=" and bm=“" & bm(1) & "“"end ifzgs(0)=Checkbox2.getChecked()if zgs(0) thenzgs(1)=Listbox2.getText(Listbox2.selectedIndex )str=str & " and zgs =“"& zgs(1) & "“"end ifxmz(0)=Checkbox3.getChecked()if xmz(0) thenxmz(1)=trim(txtxmz.value )str=str & " and xmz like “%" & xmz(1) & "%“"end ifxm(0)=Checkbox4.getChecked()if xm(0) thenxm(1)=trim(tztxm.value )str=str & " and xm like “%" & xm(1) & "%“"end ifszfx(0)=Checkbox5.getChecked()if szfx(0) thenszfx(1)=Listbox3.getText(Listbox3.selectedIndex )str =str & " and szfx =“" & szfx(1) & "“"end ifszxs(0)=Checkbox6.getChecked()if szxs(0) thenszxs(1)=Listbox4.getText(Listbox4.selectedIndex )str =str & " and szxs =“" & szxs(1) & "“"end ifjbr(0)=Checkbox8.getChecked()if jbr(0) thenjbr(1)=trim(txtjbr.value )str =str & " and jbr like “%" & jbr(1) & "%“"end ifset cnn2=server.CreateObject("adodb.connection")set rst2=server.CreateObject("adodb.recordset")cnn2.CursorLocation=3cnn2.ConnectionTimeout =30cnn2.Open "dsn=jky"Response.Write ""Response.Write ""Response.Write " "Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""if session("Tright")="1" then“Response.Write "AAAAAAAA"rst2.Open "select * from jzpz where id>0 and lrr=“" & session("username") & "“" & str ,cnn2,1,1,adcmdtextelse“Response.Write "FFFFFFFFFFFFF"rst2.Open "select * from jzpz where id>0 " & str ,cnn2,1,1,adcmdtextend ifif rst2.RecordCount >0 thenrst2.MoveFirstrst2.PageSize =20rst2.AbsolutePage =1i=0do while not rst2.EOF and i< rst2.PageSize Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""Response.Write ""i=i+1rst2.MoveNext loopend ifResponse.Write "
"Response.Write "

记 帐 凭 证 列 表"Response.Write "

"Response.Write "部 门"Response.Write "子公司"Response.Write "项目组"Response.Write "项目名/合同号"Response.Write "收入金额(万元)"Response.Write "支出金额(万元)
"& rst2.Fields("bm")& ""& rst2.Fields("zgs")& ""& rst2.Fields("xmz")& "" & rst2.Fields("xm")& ""& rst2.Fields("sr")& ""& rst2.Fields("zc")& "
"Response.Write "
"j= rst2.PageCountResponse.Write "

共有页数: " for i=1 to jResponse.Write "" & i & "" & " "if j mod 10= 0 thenResponse.Write "
"end ifnext Response.Write "

"rst2.Closecnn2.Close …………end sub  应用以上程序,可以根据用户的权限,按照用户的要求实行订制查询,该系统在win NT、IIS4.0和win98、PWS上运行通过。

相关内容