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

📄 acceptinsertusertable.jsp

📁 feemanager是思维管理类系统
💻 JSP
字号:
<%@ page contentType="text/html;charset=GBK"%>
<%@ page pageEncoding="GBK"%>
<%@ page import="java.sql.*" %>

<%!
public String codeToString(String str)
{
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
} 
%>
<%
  int dipage=1;
  String pages=request.getParameter("dipage");
  if (pages==null)
  {
     pages="1";
  }
  try
  {
    dipage=Integer.parseInt(pages);
  }
  catch (Exception e)
  {
    dipage=1;
  }  

//接收客户端提交的数据
String feedate=request.getParameter("feedate");
if (feedate==null)
feedate="";

String username=request.getParameter("username");
if (username==null)
username="";
String waterdun=codeToString(request.getParameter("waterdun"));
float dunfloat;
try
{
  dunfloat=Float.parseFloat(waterdun.trim());  
}
catch(Exception e)
{
  dunfloat=0;
}
String elecdu=codeToString(request.getParameter("elecdu"));
float dufloat;
try
{
  dufloat=Float.parseFloat(elecdu.trim());  
}
catch(Exception e)
{
  dufloat=0;
}

String waterdj=request.getParameter("waterdj");
String elecdj=request.getParameter("elecdj");
String sumje=request.getParameter("sumje");

String feedatetj=codeToString(request.getParameter("feedatetj"));
String usernametj=request.getParameter("usernametj");

//构造追加纪录SQL
String sqlString=null;
sqlString="insert into feelist(khmc,waternum,waterdj,elecnum,elecdj,sumfee,begintoend) values('"+username+"',"+dunfloat+","+waterdj+","+dufloat+","+elecdj+","+sumje+",'"+feedate+"')";

		 //执行SQL语句
		   Connection con;
		   Statement sql;
		   ResultSet rs;
		   try
		   {
		     Class.forName("oracle.jdbc.driver.OracleDriver");
		   }
		   catch(ClassNotFoundException e)
		   {
		    out.print("类找不到!");
		   }
//		   try
//		   {         
  		   con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ywjygl","feemanager","chuyanjun");
		     sql=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
		     if (username!="")
		     {
		     sql.executeUpdate(sqlString);
		     }
		     
		     if (feedate == "")
		     {
		        sqlString="select id,khmc,waternum,waterdj,elecnum,elecdj,sumfee,begintoend from feelist";		     
		     }
		     else
		     {
		        sqlString="select id,khmc,waternum,waterdj,elecnum,elecdj,sumfee,begintoend from feelist where begintoend='"+feedate+"'";		     
		     }
		    	
		     if (feedatetj==null||feedatetj.trim().length()==0)	
		       ;
		     else
		     	if (sqlString.indexOf("where")==-1)
		     	  sqlString=sqlString+" where begintoend='"+feedatetj+"'";
		     	else
		     		sqlString=sqlString+" and begintoend='"+feedatetj+"'";
		     		
		     if (usernametj==null||usernametj.trim().length()==0)	
		       ;
		     else
		     	if (sqlString.indexOf("where")==-1)
		     	  sqlString=sqlString+" where khmc='"+usernametj+"'";
		     	else
		     		sqlString=sqlString+" and khmc='"+usernametj+"'";	
         
         sqlString=sqlString+" order by id";
		     rs=sql.executeQuery(sqlString);
		    
		     int countRecord=0;
		     int countPageRecord=0;
		     int countPage=0;
		     countPageRecord=10;
		    
		     rs.last();
		     countRecord=rs.getRow();
		     
		     if (countRecord%countPageRecord==0)
		         countPage=countRecord/countPageRecord;
		     else
		     	   countPage=countRecord/countPageRecord+1;
		     	   
		     if ((dipage-1)*countPageRecord==0)
		         rs.beforeFirst();
		     else
		     	   rs.absolute((dipage-1)*countPageRecord);		     	   	   
		     
		     out.print("<center>");
		     out.print("<Table Border>");
		     out.print("<form action=acceptInsertUserTable.jsp method=post>");
		     out.print("<TR><td>查询条件</td>");
		     out.print("<td colspan=7>");
		     out.print("费用期间:<input type=text name=feedatetj>");
		     out.print("&nbsp;姓名:<input type=text name=usernametj>");
		     out.print("<input type=submit value=提交>");
		     out.print("</td></tr></form>");		     
		     
		     out.print("<TR><td colspan=8 align=center>用户数据</td></tr>");
		     out.print("<TR>");
		       out.print("<Td width=100>"+"客户名称");
		       out.print("<Td width=100>"+"水(吨)");
		       out.print("<Td width=100>"+"单价(元/吨)");
		       out.print("<Td width=100>"+"电(度)");
		       out.print("<Td width=100>"+"单价(元/度)");
		       out.print("<Td width=100>"+"合计");
		       out.print("<Td width=100>"+"费用期间");
		       out.print("<Td width=50>"+"删除");
		     out.print("</TR>");  
		     int i=0;
		   while(rs.next())
		   { out.print("<TR>");
		         out.print("<TD>"+codeToString(rs.getString(2))+"</TD>");
		         out.print("<TD>"+rs.getString(3)+"</TD>");
		         out.print("<TD>"+rs.getString(4)+"</TD>");
		         out.print("<TD>"+rs.getString(5)+"</TD>");
		         out.print("<TD>"+rs.getString(6)+"</TD>");
		         out.print("<TD>"+rs.getString(7)+"</TD>");		         
		         out.print("<TD>"+codeToString(rs.getString(8))+"</TD>");
		         out.print("<TD align=center><a href='deleteUser2.jsp?user_id="+rs.getInt(1)+"'>×</a></TD>");		         
		     out.print("</TR>");
		     i++;
		     if (i>=countPageRecord) break;
		   }
		   out.print("<TR><td colspan=8 align=center>");
		   out.print("共"+countRecord+"条纪录,共"+countPage+"页,当前第"+dipage+"页,每页"+countPageRecord+"条纪录,");
		   if (dipage==1)
		      ;
		   else
		   	{
		   	  out.print("<a href=acceptInsertUserTable.jsp?dipage=1>首页</a>,");
		   	  out.print("<a href=acceptInsertUserTable.jsp?dipage="+(dipage-1)+">上一页</a>,");
		   	}
		   	if (dipage==countPage)
		   	  ;
		   	else
		   		{
		   		   out.print("<a href=acceptInsertUserTable.jsp?dipage="+(dipage+1)+">下一页</a>,");
		   		   out.print("<a href=acceptInsertUserTable.jsp?dipage="+countPage+">末页</a>");
		   		}
		   out.print("</td></TR>");
		   
		   out.print("</Table>");
		   out.print("<TD><a href='index.jsp'>返回</a>");	
		   con.close();
//		   }
//		   catch(SQLException e1)
//		   {
//		     out.print("SQL异常!");
//		   }
		%>
	</BODY>
</HTML>

⌨️ 快捷键说明

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