package com.jspdev;
import com.db.DataBaseManager;
import com.jspdev.*;
import java.sql.*;
import java.sql.Date;
import javax.sql.*;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
public class RecordBean {
private Connection con;
public RecordBean()throws Exception{
this.con=DataBaseManager.getConnection();
con.setAutoCommit(false);
}
public int Park()throws Exception{
int cypark_num = 0;
Statement stmt=con.createStatement();
ResultSet rs1=stmt.executeQuery("select count(*) from parking where state=0");
while(rs1.next()){
cypark_num=rs1.getInt(1);
}
return cypark_num;
}
public boolean insertSqla(String car_num,int park_num,int catenum,String park_time)
{
try{
Statement stmt=con.createStatement();
stmt.execute("insert into record(car_num,park_num,catenum,park_time) values('"+car_num+"',"+park_num+","+catenum+",'"+park_time+"')");
con.commit();
return true;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return false;
}
}
public ResultSet reco()throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet zrecord()throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet xrecord()throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where park_num=6");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet dname(String name)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where name='"+name+"'");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet did(String id)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where id_num='"+id+"'");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet dpark(int park)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where park_num="+park);
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet dcar(String car)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where car_num='"+car+"'");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet dusercate(String usercate)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where usercate='"+usercate+"'");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet sday(Date parktime)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where park_time>'"+parktime+"'");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public ResultSet sday1(String parktime)throws Exception
{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
ResultSet rs=stmt.executeQuery("select*from record where park_time>'"+parktime+"'");
return rs;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return null;
}}
public boolean xname(String car_num,String name)throws Exception{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
stmt.executeUpdate("update customer set name='"+name+"' where car_num='"+car_num+"'");
con.commit();
return true;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return false;
}
}
public boolean xid(String car_num,String id)throws Exception{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
stmt.executeUpdate("update customer set id_num='"+id+"' where car_num='"+car_num+"'");
con.commit();
return true;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return false;
}
}
public boolean xcarnum(String car_num,String carnum)throws Exception{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
stmt.executeUpdate("update customer set car_num='"+carnum+"' where car_num='"+car_num+"'");
con.commit();
return true;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return false;
}
}
public int getResult(String car_num)throws Exception
{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("select*from record where car_num='"+car_num+"' and tunrout_time is null");
boolean isExist=false;
int catenum = 0;
try
{
isExist=rs.first();
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
}
if(isExist){
catenum=rs.getInt("catenum");
}else{
catenum=1;
}
return catenum;
}
public String time(String car_num)throws Exception
{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("select*from record where car_num='"+car_num+"' and tunrout_time is null");
boolean isExist=false;
String park_time = "";
try
{
isExist=rs.first();
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
}
if(isExist){
park_time=rs.getString("park_time");
}else{
park_time="1";
}
return park_time;
}
public boolean turnout(String car_num,String time)throws Exception{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
stmt.executeUpdate("update record set tunrout_time='"+time+"' where car_num='"+car_num+"' and tunrout_time is null");
con.commit();
return true;
}
catch(SQLException sqle)
{
System.out.println(sqle.toString());
return false;
}
}
public boolean turnoutb(String car_num,String time,BigDecimal chargs)throws Exception{
try{
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSe
- 1
- 2
- 3
- 4
前往页