⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jcy_ry_sczp.jsp

📁 公务员工资系统软件工程文档及源代码
💻 JSP
字号:
<%@page language="java" contentType="text/html;charset=GBK" %>
<%@page import="java.sql.*" %> 
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="com.jspsmart.upload.*"%> 
<%@page import="javax.sql.DataSource"%>
<%@page import="javax.naming.Context"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="sun.jdbc.rowset.*"%>
<%@page import = "com.vstsoft.std.*" %>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /> 
<jsp:useBean id="jcypurview" class="com.vstsoft.jcypurview" scope = "session" />
<%
  String currusercode = jcypurview.getUsercode(); //取当前用户usercode
  String curruserid = jcypurview.getUserid();     //取当前用户编号
  String currusername = jcypurview.getUserName(); //取当前用户名称
  String curruserszqx = jcypurview.getUserSzqx(); //取当前用户所在区县 
  String curruserszdw = jcypurview.getUserSzdw(); //取当前用户所在单位

//检测用户是否登录
if (jcypurview.checkLogin() == false)
   {
%>   
	<Script Language=javascript>
		alert("用户已断线或未正常登录,请重新登录!")
		window.open("../index.htm","_top")
	</Script>
<%  
    return;}
%>
<%
  //检测用户是否有操作权限 
  if (!(jcypurview.purviewVerdict("B0500001") || jcypurview.purviewVerdict("B0500010")))
  {
%>
	<Script Language=javascript>
		alert("您没有操作此页权限!")
		history.go(-1);
	</Script>
<%	return;
   }
%> 
<%vststd std = new vststd();%>
<%
	String uid=std.getValue(request,"uid");
	String errtext = "";
	int i = 0;
	if (!uid.equals("")){
		String sqlSel = "select ryzt, qx from jcy_ry where userid = '"+uid+"'";
		sun.jdbc.rowset.CachedRowSet crs = std.getResultBySelect(sqlSel);
		crs.next();
		String ryzt = crs.getString(1);
		String qx   = crs.getString(2);

		if (ryzt.equals("04") && (!curruserszqx.equals(qx))){
			errtext = "您不具有修改此公务员信息的权限!只有本区系统管理员可以修改!";
			i = 1;
		}
		else if ((ryzt.equals("05") || ryzt.equals("06")) && (!curruserszqx.equals("001"))){
			errtext = "您不具有修改此公务员信息的权限!只有市处系统管理员可以修改!";
			i = 1;
		}
		else if (ryzt.equals("03") && (!curruserszqx.equals("001")) && (!curruserszqx.equals(qx))){
			errtext = "您不具有修改此公务员信息的权限!只有本区系统管理员或者市处系统管理员可以修改!";
			i = 1;
		}
		else if (ryzt.equals("02"))
			errtext = "此公务员信息不可修改!";
	}
%>
<%
if (i == 0){
mySmartUpload.init(config); 
mySmartUpload.service(request,response); 
//Set Restriction 
mySmartUpload.setAllowedFilesList("bmp,jpg,gif,png"); 
mySmartUpload.setTotalMaxFileSize(1000000); 
try{ 
	mySmartUpload.upload(); 
} 
catch(Exception e){
//	System.out.println(e.getMessage());
	errtext = "上传失败!请检查您所上传的文件类型及大小。";
	out.println("<body onLoad=\"parent.f_sczperr('"+errtext+"')\"></body>");
	return; 
}

response.setHeader("Cache-control", "no-store");
response.setHeader("Pragma", "no-cache");

String grid="" ;
String bugid=request.getParameter("bugid");
String filename,filetype,filenameall;
int filelength ;

filename = mySmartUpload.getFiles().getFile(0).getFileName();
filelength=filename.length()-4;
filetype = filename.substring(filelength) ;
filenameall = bugid+filetype ;
int filelong = mySmartUpload.getFiles().getFile(0).getSize();
Vector vec,vec1 ;
String sfcg ;
int vec_size;

vststd pms = new vststd("jc");
Context ctx = null;
DataSource ds = null;
Connection con = null;
Statement stmt = null;


	ctx = new InitialContext();
	ds  = (DataSource)ctx.lookup("jc");
	try{
		con = ds.getConnection();
		stmt= con.createStatement();
		con.setAutoCommit(false);
	}catch(SQLException ex){
		System.out.println(ex.getMessage());
	}

	if (!uid.equals("")){
		ResultSet rs=null;

		try{
			String sqlDel = "delete from jcy_ryzp where userid = '"+uid+"'";//删除之前的照片
			pms.getResultByUpdate(sqlDel);
			String sqlIns = "insert into jcy_ryzp (userid,zp) values ('"+uid+"',empty_blob())";
			pms.getResultByUpdate(sqlIns);
			String sqlSel = "select zp from jcy_ryzp where userid='"+uid+"' for update";
			rs=stmt.executeQuery(sqlSel);


			byte buffer[] = new byte[filelong];
			for(int b = 0 ;b < filelong ; b++){
				buffer[b] = mySmartUpload.getFiles().getFile(0).getBinaryData(b);
			}
			out.println(buffer.length+"");


			if(rs.next())
			{
				java.sql.Blob blob = rs.getBlob("zp");
				OutputStream outStream = ((weblogic.jdbc.vendor.oracle.OracleThinBlob)blob).getBinaryOutputStream();
				for(int a=0;a<buffer.length;a++){
					outStream.write(buffer[a]); 
				}

				outStream.flush();

				outStream.close();
				stmt.execute("commit");
				//System.out.println("文件成功写入数据库");
			}
				errtext="zpok";
			}
			catch(SQLException ex)
			{
				System.out.println(ex.toString());
				errtext="有错误发生!";
			}
		}
	else if (uid.equals("")){
		ResultSet rs=null;

		try{
			String sqlDel = "delete from t_zp where id = '1'";
			pms.getResultByUpdate(sqlDel);
			String sqlIns = "insert into t_zp (id,zp) values ('1',empty_blob())";
			pms.getResultByUpdate(sqlIns);
			String sqlSel = "select zp from t_zp where id='1' for update";
			rs=stmt.executeQuery(sqlSel);

			byte buffer[] = new byte[filelong];
			for(int b = 0 ;b < filelong ; b++){
				buffer[b] = mySmartUpload.getFiles().getFile(0).getBinaryData(b);
			}
			out.println(buffer.length+"");

			if(rs.next())
			{
				java.sql.Blob blob = rs.getBlob("zp");
				OutputStream outStream = ((weblogic.jdbc.vendor.oracle.OracleThinBlob)blob).getBinaryOutputStream();
				for(int a=0;a<buffer.length;a++){
					outStream.write(buffer[a]); 
				}
			outStream.flush();

			outStream.close();
			stmt.execute("commit");
			//System.out.println("文件成功写入数据库");
			}	
			errtext="zpok";
		}
		catch(SQLException ex)
		{
		out.println(ex.toString());
		errtext="有错误发生!";
		}
	}
}
%>
<html>
<head>
<title>无标题文档</title>
</head>
<body onLoad="parent.f_sczperr('<%=errtext%>')">

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -