📄 iteminfobean.java
字号:
package Model_ItemInfo;
import DataBase.ConDataBase;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
public class ItemInfoBean
{
public ItemInfoBean()
{
}
public String InsertItemInfo(ItemInfo ii)
{
Connection con=ConDataBase.getConnection();
try{
CallableStatement cmst=con.prepareCall("{call INSERTITEMINFO(?,?,?,?,?,?,?,?,?)}");
cmst.setString(1,ii.getItemID());
cmst.setString(2,ii.getPetID());
cmst.setString(3,ii.getRetailPrice());
cmst.setString(4,ii.getCostPrice());
cmst.setString(5,ii.getSupID());
cmst.setString(6,ii.getAttr1());
cmst.setString(7,ii.getAttr2());
cmst.setString(8,ii.getAttr3());
cmst.registerOutParameter(9,Types.VARCHAR);
cmst.execute();
String re=cmst.getString(9);
return re;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
}
public String UpdateItemInfo(ItemInfo ii)
{
Connection con=ConDataBase.getConnection();
try{
CallableStatement cmst=con.prepareCall("{call UPDATEITEMINFO(?,?,?,?,?,?,?,?,?)}");
cmst.setString(1,ii.getItemID());
cmst.setString(2,ii.getPetID());
cmst.setString(3,ii.getRetailPrice());
cmst.setString(4,ii.getCostPrice());
cmst.setString(5,ii.getSupID());
cmst.setString(6,ii.getAttr1());
cmst.setString(7,ii.getAttr2());
cmst.setString(8,ii.getAttr3());
cmst.registerOutParameter(9,Types.VARCHAR);
cmst.execute();
String re=cmst.getString(9);
return re;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
}
public String DeleteItemInfo(String itemid)
{
Connection con=ConDataBase.getConnection();
try{
CallableStatement cmst=con.prepareCall("{call DELETEITEMINFO(?,?)}");
cmst.setString(1,itemid);
cmst.registerOutParameter(2,Types.VARCHAR);
cmst.execute();
String re=cmst.getString(2);
return re;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
}
public Collection FindItem(String itemid)
{
Connection con=ConDataBase.getConnection();
ArrayList al=new ArrayList();
try{
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from vtype where TypeID='"+itemid+"' and rownum<=9");
while (rs.next())
{
ItemInfo ii=new ItemInfo();
ii.setItemID(rs.getString(4));
ii.setPetID(rs.getString(1));
ii.setRetailPrice(rs.getString(5));
ii.setAttr1(rs.getString(3));//存储的是图片
al.add(ii);
}
return al;
}
catch(Exception e)
{
return null;
}
}
public Collection FindAllItem()
{
Connection con=ConDataBase.getConnection();
ArrayList al=new ArrayList();
try{
Statement st=con.createStatement();
//ResultSet rs=st.executeQuery("select * from (select * from ItemInfo order by retailprice desc) where rownum<=9");
ResultSet rs=st.executeQuery("select * from ItemInfo");
while (rs.next())
{
ItemInfo ii=new ItemInfo();
ii.setItemID(rs.getString(1));
ii.setPetID(rs.getString(2));
ii.setRetailPrice(rs.getString(3));
ii.setCostPrice(rs.getString(4));
ii.setSupID(rs.getString(5));
ii.setAttr1(rs.getString(6));
ii.setAttr2(rs.getString(7));
ii.setAttr3(rs.getString(8));
al.add(ii);
}
return al;
}
catch(Exception e)
{
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -