ruleSetOp.jsp
4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<%@page import="weaver.fna.maintenance.FnaCostCenter"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@page import="org.json.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*,java.sql.Timestamp" %>
<%@ page import="weaver.general.GCONST" %>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page" />
<%
StringBuffer result = new StringBuffer();
User user = HrmUserVarify.getUser (request , response) ;
if(user == null){
response.sendRedirect("/notice/noright.jsp") ;
return ;
}else{
if(!HrmUserVarify.checkUserRight("BudgetOrgPermission:settings",user) && !HrmUserVarify.checkUserRight("FnaSystemSetEdit:Edit",user)){
response.sendRedirect("/notice/noright.jsp") ;
return ;
}
String op = Util.null2String(request.getParameter("op")).trim();
int id = Util.getIntValue(request.getParameter("id"), 0);
String name = Util.null2String(request.getParameter("name")).trim();
int roleid = Util.getIntValue(request.getParameter("field6599"), 0);
String depids = Util.null2String(request.getParameter("field6855")).trim();
int oldroleid = Util.getIntValue(request.getParameter("oldroleid"), 0);
int allowZb = Util.getIntValue(request.getParameter("allowZb"), 0);
int allowFb = Util.getIntValue(request.getParameter("allowFb"), 0);
int allowBm = Util.getIntValue(request.getParameter("allowBm"), 0);
int allowFcc = Util.getIntValue(request.getParameter("allowFcc"), 0);
String fbids = Util.null2String(request.getParameter("field6341")).trim();
String fccids = Util.null2String(request.getParameter("fccids")).trim();
if("add".equals(op) || "edit".equals(op) || "del".equals(op) || "batchDel".equals(op)){
String operateType = id>0?"2":"1";
if("add".equals(op) || "edit".equals(op)){
String _sql = "select count(*) cnt from FnaRuleSet where id <> "+id+" and roleid = "+roleid;
rs1.executeSql(_sql);
if(rs1.next() && rs1.getInt("cnt") > 0){
out.println("{\"flag\":false,\"msg\":"+JSONObject.quote(SystemEnv.getHtmlLabelName(122,user.getLanguage())+SystemEnv.getHtmlLabelName(24943,user.getLanguage()))+"}");//角色已存在
out.flush();
return;
}
}
String _sql = "DELETE from FnaRuleSetDtl where mainid = (select FnaRuleSet.id from FnaRuleSet where FnaRuleSet.roleid = "+oldroleid+")";
rs1.executeSql(_sql);
_sql = "DELETE from FnaRuleSet where roleid = "+oldroleid;
rs1.executeSql(_sql);
if("add".equals(op) || "edit".equals(op)){
_sql = "insert into FnaRuleSet (roleid, name, allowZb, allowFb, allowBm, allowFcc) "+
"values ("+roleid+", '"+StringEscapeUtils.escapeSql(name)+"', "+allowZb+", "+allowFb+", "+allowBm+", "+allowFcc+")";
rs1.executeSql(_sql);
_sql = "select id from FnaRuleSet where roleid = "+roleid;
rs1.executeSql(_sql);
if(rs1.next()){
id = rs1.getInt("id");
if(!"".equals(fbids) && allowFb==4){
String[] fbidsArray = fbids.split(",");
for(int i=0;i<fbidsArray.length;i++){
int fbid = Util.getIntValue(fbidsArray[i]);
if(fbid > 0){
_sql = "insert into FnaRuleSetDtl (mainid, showid, showidtype) values ("+id+", "+fbid+", 1)";
rs1.executeSql(_sql);
}
}
}
if(!"".equals(depids) && allowBm==4){
String[] depidsArray = depids.split(",");
for(int i=0;i<depidsArray.length;i++){
int depid = Util.getIntValue(depidsArray[i]);
if(depid > 0){
_sql = "insert into FnaRuleSetDtl (mainid, showid, showidtype) values ("+id+", "+depid+", 2)";
rs1.executeSql(_sql);
}
}
}
if(!"".equals(fccids) && allowFcc==4){
String[] fccidsArray = fccids.split(",");
for(int i=0;i<fccidsArray.length;i++){
int fccid = Util.getIntValue(fccidsArray[i]);
if(fccid > 0){
_sql = "insert into FnaRuleSetDtl (mainid, showid, showidtype) values ("+id+", "+fccid+", "+FnaCostCenter.ORGANIZATION_TYPE+")";
rs1.executeSql(_sql);
}
}
}
}
out.println("{\"flag\":true,\"msg\":"+JSONObject.quote(SystemEnv.getHtmlLabelName(18758,user.getLanguage()))+"}");
out.flush();
return;
}else if("del".equals(op) || "batchDel".equals(op)){
String batchDelIds = Util.null2String(request.getParameter("batchDelIds")).trim();
if("del".equals(op)){
batchDelIds = id+",";
}
batchDelIds += "-1";
_sql = "DELETE from FnaRuleSetDtl where mainid in ("+batchDelIds+")";
rs1.executeSql(_sql);
_sql = "DELETE from FnaRuleSet where id in ("+batchDelIds+")";
rs1.executeSql(_sql);
out.println("{\"flag\":true,\"msg\":"+JSONObject.quote(SystemEnv.getHtmlLabelName(18758,user.getLanguage()))+"}");
out.flush();
return;
}
}else{
response.sendRedirect("/notice/noright.jsp") ;
return ;
}
}
%>