📄 toubiaobo.java
字号:
package C03.BO;
import java.io.UnsupportedEncodingException;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import C03.VO.*;
import C03.CDB.*;
public class toubiaoBO {
dataBase db;
public toubiaoBO() {
db = new dataBase();
}
public boolean toubiao(String project_ID, String user_NAME, String tb_cost,
String tb_content) throws UnsupportedEncodingException {
Date date = new Date();
SimpleDateFormat date1 = new SimpleDateFormat("yyyy-MM-dd");
String tb_TIME = date1.format(date);
String sql = "insert toubiaoTable values('" + project_ID + "','"
+ user_NAME + "','" + tb_TIME + "','0','" + tb_cost + "','"
+ tb_content + "')";
sql = new String(sql.getBytes("ISO-8859-1"), "GB2312");
if (db.sqlUpdata(sql))
return true;
else
return false;
}
public Vector fildtoubiao(String username) {
Vector vc = new Vector();
String sql = "select * from toubiaoTable where user_name='" + username
+ "'";
String project_id = "";
ResultSet rs = db.sqlFind(sql);
dataBase db1 = new dataBase();
try {
while (rs.next()) {
toubiaoBean tb = new toubiaoBean();
tb.settoubiao_ID(rs.getString(1));
project_id = rs.getString(2);
tb.setproject_ID(project_id);
tb.setuser_NAME(rs.getString(3));
tb.settb_TIME(rs.getString(4));
tb.setgettb_ZT(rs.getString(5));
tb.setTb_cost(rs.getString(6));
tb.setTb_content(rs.getString(7));
sql = "select * from project where project_id='" + project_id
+ "'";
ResultSet rs1 = db1.sqlFind(sql);
if (rs1.next()) {
tb.setProject_id(rs1.getString(1));
tb.setProject_name(rs1.getString(2));
tb.setProject_time(rs1.getString(3));
tb.setProject_company(rs1.getString(4));
tb.setProject_cost(rs1.getString(5));
tb.setProject_content(rs1.getString(6));
}
vc.addElement(tb);
}
} catch (Exception e) {
System.out.println("BO.toubiaoBO.fildtoubiao()方法出错" + e.toString());
return null;
}
return vc;
}
public boolean fildtoubiao(String username, String project_ID) {
String sql = "select * from toubiaoTable where user_NAME='" + username
+ "'and project_ID='" + project_ID + "'";
ResultSet rs = db.sqlFind(sql);
try {
if (rs.next()) {
return true;
} else
return false;
} catch (Exception e) {
return false;
}
}
public Vector fildtoubiaouser(String project_id) {
Vector vc = new Vector();
String sql = "select * from toubiaoTable where project_id='"+project_id+"'";
ResultSet rs = db.sqlFind(sql);
dataBase db1 = new dataBase();
try{
while(rs.next()){
toubiaouserBean bean = new toubiaouserBean();
bean.setTb_id(rs.getString(1));
String tb_username=rs.getString(3);
bean.setTb_username(tb_username);
bean.setTb_time(rs.getString(4));
bean.setTb_zt(rs.getString(5));
bean.setTb_cost(rs.getString(6));
bean.setTb_content(rs.getString(7));
sql = "select * from userTable where userName='"+tb_username+"'";
ResultSet rs1 = db1.sqlFind(sql);
if(rs1.next()){
bean.setTb_usercompany(rs1.getString(3));
bean.setTb_useraddress(rs1.getString(4));
}
vc.addElement(bean);
}
}catch(Exception e){
System.out.println("BO.toubiaoBO.fildtoubiaouser()方法错误"+e.toString());
}
return vc;
}
public boolean updatatoubiao(String tb_id){
db = new dataBase();
String sql = "update toubiaoTable set tb_zt='1' where toubiao_id='"+tb_id+"'";
boolean i = db.sqlUpdata(sql);
return i;
}
public boolean deltoubiao(String tb_id){
db = new dataBase();
String sql ="delete from toubiaoTable where toubiao_id='"+tb_id+"'";
boolean i = db.sqlUpdata(sql);
if(i)return true;
else return false;
}
public boolean fildprojectuser(String project_id,String project_username){
String sql = "select * from project where project_id='"+project_id+"' and project_username='"+project_username+"'";
db = new dataBase();
ResultSet rs = db.sqlFind(sql);
try{
if(rs.next()) return true;
else return false;
}catch(Exception e){
System.out.println("BO.toubiaoBO.fildprojectuser错误"+e.toString());
return false;
}
}
public Vector returntoubiao(String toubiao_id){
Vector vc = new Vector();
String sql = "select * from toubiaoTable where toubiao_id='" + toubiao_id
+ "'";
String project_id = "";
ResultSet rs = db.sqlFind(sql);
dataBase db1 = new dataBase();
try {
if (rs.next()) {
toubiaoBean tb = new toubiaoBean();
tb.settoubiao_ID(rs.getString(1));
project_id = rs.getString(2);
tb.setproject_ID(project_id);
tb.setuser_NAME(rs.getString(3));
tb.settb_TIME(rs.getString(4));
tb.setgettb_ZT(rs.getString(5));
tb.setTb_cost(rs.getString(6));
tb.setTb_content(rs.getString(7));
sql = "select * from project where project_id='" + project_id
+ "'";
ResultSet rs1 = db1.sqlFind(sql);
if (rs1.next()) {
tb.setProject_id(rs1.getString(1));
tb.setProject_name(rs1.getString(2));
tb.setProject_time(rs1.getString(3));
tb.setProject_company(rs1.getString(4));
tb.setProject_cost(rs1.getString(5));
tb.setProject_content(rs1.getString(6));
}
vc.addElement(tb);
}
} catch (Exception e) {
System.out.println("BO.toubiaoBO.fildtoubiao()方法出错" + e.toString());
return null;
}
return vc;
}
public boolean udatatoubiao(String toubiao_id,String tb_cost,String tb_content)
throws UnsupportedEncodingException {
String sql = "update toubiaoTable set tb_cost='"+tb_cost+"',tb_content='"+tb_content+"' where toubiao_id='"+toubiao_id+"'" ;
sql = new String(sql.getBytes("ISO-8859-1"),"GB2312");
db = new dataBase();
boolean i = db.sqlUpdata(sql);
return true;
}
public String returnproject(String tb_id){
String sql = "select * from toubiaoTable where toubiao_id='"+tb_id+"'";
db = new dataBase();
ResultSet rs = db.sqlFind(sql);
try{
if(rs.next()){
String project_id=rs.getString(2);
return project_id;
}else return null;
}catch(Exception e){
System.out.println("BO.toubiaoBO.returnproject()错误"+e.toString());
return null;
}
}
public String returnusername(String tb_id){
String sql = "select * from toubiaoTable where toubiao_id='"+tb_id+"'";
db = new dataBase();
ResultSet rs = db.sqlFind(sql);
try{
if(rs.next()){
return rs.getString(3);
}else return null;
}catch(Exception e){
System.out.println("BO.toubiaoBO.returnproject()错误"+e.toString());
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -