bjupdateaction.java
来自「功能是公安和学校的管理系统,用struts+hibernate+spring等匡」· Java 代码 · 共 149 行
JAVA
149 行
package com.comingnet.action;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Date;
import com.db.ProxoolAction;
import com.opensymphony.xwork2.ActionSupport;
public class bjupdateaction extends ActionSupport {
private static final long serialVersionUID = -495460392285123334L;
int xxbh;
public int getXxbh() {
return xxbh;
}
public void setXxbh(int xxbh) {
this.xxbh = xxbh;
}
@Override
public String execute() throws Exception {
//定义数据库连接字段
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs=null;
PreparedStatement stmt1=null;
ResultSet rs1=null;
//判断当前月份是否可以升级之
Date now=new Date();
int curryear=now.getYear()+1900;
try {
conn=ProxoolAction.getConnection();
stmt=conn.prepareStatement("select bjid,bjnj,bjrxnf,bjbynf,bjmcstr,xnz,bjmc from m_class where xxbh="+xxbh);
rs=stmt.executeQuery();
while(rs.next())
{
int bjid=0;
int bjnj=0;
java.sql.Date bjrxnf=null;
java.sql.Date bjbynf=null;
String bjmcstr=null;
String njmcstr=null;
String currbjmc=null;
int xnz=0;
bjid=rs.getInt(1);
bjnj=rs.getInt(2);
bjrxnf=rs.getDate(3);
bjbynf=rs.getDate(4);
bjmcstr=rs.getString(5);
xnz=rs.getInt(6);
currbjmc=rs.getString(7);
if(xnz==5)
{
if(bjnj<5&&bjnj>0)
{
int bjnjnew=bjnj+1;
stmt1=conn.prepareStatement("select njmc from m_nianji where njid="+bjnjnew);
rs1=stmt1.executeQuery();
while(rs1.next())
{
njmcstr=rs1.getString(1);
}
ProxoolAction.closeResultSet(rs1);
ProxoolAction.closeStatement(stmt1);
stmt1=conn.prepareStatement("update m_class set bjnj=?,bjmc=? where bjid="+bjid);
stmt1.setInt(1, bjnjnew);
stmt1.setString(2, njmcstr+bjmcstr);
stmt1.executeUpdate();
ProxoolAction.closeStatement(stmt1);
}else if(bjnj==5)
{
stmt1=conn.prepareStatement("update m_class set bjnj=0,bjmc=?,bjby=1 where bjid="+bjid);
stmt1.setString(1, curryear+"届"+currbjmc);
stmt1.executeUpdate();
ProxoolAction.closeStatement(stmt1);
}
}else if(xnz==6)
{
if(bjnj<6&&bjnj>0)
{
int bjnjnew=bjnj+1;
stmt1=conn.prepareStatement("select njmc from m_nianji where njid="+bjnjnew);
rs1=stmt1.executeQuery();
while(rs1.next())
{
njmcstr=rs1.getString(1);
}
ProxoolAction.closeResultSet(rs1);
ProxoolAction.closeStatement(stmt1);
stmt1=conn.prepareStatement("update m_class set bjnj=?,bjmc=? where bjid="+bjid);
stmt1.setInt(1, bjnjnew);
stmt1.setString(2, njmcstr+bjmcstr);
stmt1.executeUpdate();
ProxoolAction.closeStatement(stmt1);
}else if(bjnj==6)
{
stmt1=conn.prepareStatement("update m_class set bjnj=0,bjmc=?,bjby=1 where bjid="+bjid);
stmt1.setString(1, curryear+"届"+currbjmc);
stmt1.executeUpdate();
ProxoolAction.closeStatement(stmt1);
}
}else if(xnz==3)
{
if(bjnj>=7&&bjnj<=12&&bjnj!=9&&bjnj!=12)
{
int bjnjnew=bjnj+1;
stmt1=conn.prepareStatement("select njmc from m_nianji where njid="+bjnjnew);
rs1=stmt1.executeQuery();
while(rs1.next())
{
njmcstr=rs1.getString(1);
}
ProxoolAction.closeResultSet(rs1);
ProxoolAction.closeStatement(stmt1);
stmt1=conn.prepareStatement("update m_class set bjnj=?,bjmc=? where bjid="+bjid);
stmt1.setInt(1, bjnjnew);
stmt1.setString(2, njmcstr+bjmcstr);
stmt1.executeUpdate();
ProxoolAction.closeStatement(stmt1);
}else if(bjnj==9||bjnj==12)
{
stmt1=conn.prepareStatement("update m_class set bjnj=0,bjmc=?,bjby=1 where bjid="+bjid);
stmt1.setString(1, curryear+"届"+currbjmc);
stmt1.executeUpdate();
ProxoolAction.closeStatement(stmt1);
}
}
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage()+"错误");
return ERROR;
} finally {
ProxoolAction.closeResultSet(rs);
ProxoolAction.closeStatement(stmt);
ProxoolAction.closeConnection(conn);
}
return SUCCESS;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?