?? bsotherinfo.java
字號:
}
/**
* 添加新聞
* @param paymentName
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addNews(String title,
String type,
String content) throws SQLException,IOException
{
String sql = "";
sql = "insert into news(title,type,content,issueDate) " +
"VALUES('"+title+"','"+type+"','"+content+"','"+StringUtil.genDateTimeString()+"')";
dbconn.execute(sql);
}
/**
* 列出所有新聞
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Vector getAllNews()throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from news order by issueDate desc ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 刪除新聞
* @param id
* @throws SQLException
* @throws IOException
*/
public void delNews(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from news where id = '"+id+"' ";
dbconn.execute(sql);
}
/**
* 根據ID找到相應的新聞記錄
* @param id
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Map getAllNews(String id)throws SQLException,IOException
{
Vector v = null;
Map map = null;
String sql = "";
sql = "select * from news where id='"+id+"' ";
v = dbconn.ListOfMapData(sql);
if(v!=null)
map = (Map)v.get(0);
return map;
}
/**
* 修改新聞
* @param id
* @param title
* @param type
* @param content
* @throws SQLException
* @throws IOException
*/
public void modifyNews(String id,
String title,
String type,
String content)throws SQLException,IOException
{
String sql = "";
sql = "update news set title = '"+title+"',type='"+type+"'," +
"content='"+content+"',issueDate='"+StringUtil.genDateTimeString()+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 列出所有的市
* @param provinceId
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Vector getAllCity(String provinceId)throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from city ";
if(!provinceId.equals("all"))
sql = sql + " where provinceId='"+provinceId+"' ";
sql = sql + "order by sort ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 取出市的最大序號
* @return String
* @throws SQLException
* @throws IOException
*/
public String getMaxSortCity() throws SQLException,IOException
{
Vector v = null;
String sort = "";
String sql = "";
sql = "select max(sort) as sort from city ";
v = dbconn.ListOfMapData(sql);
Map map = (Map)v.get(0);
sort = (String)map.get("sort");
if(sort == null)sort="0";
return sort;
}
/**
* 添加市信息
* @param provinceId
* @param cityName
* @param cityNumber
* @param sort
* @throws SQLException
* @throws IOException
*/
public void addCity(String provinceId,
String cityName,
String cityNumber,
String sort) throws SQLException,IOException
{
String sql = "";
sql = "insert into city(provinceId,cityName,cityNumber,sort,createDate) " +
"VALUES('"+provinceId+"','"+cityName+"','"+cityNumber+"','"+sort+"'," +
"'"+StringUtil.genDateTimeString()+"')";
dbconn.execute(sql);
}
/**
* 修改市信息
* @param id
* @param provinceId
* @param cityName
* @param cityNumber
* @param sort
* @throws SQLException
* @throws IOException
*/
public void modifyCity(String id,
String provinceId,
String cityName,
String cityNumber,
String sort)throws SQLException,IOException
{
String sql = "";
sql = "update city set provinceId = '"+provinceId+"',cityName='"+cityName+"'," +
"cityNumber='"+cityNumber+"',sort='"+sort+"'," +
"createDate='"+StringUtil.genDateTimeString()+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 刪除市信息
* @param id
* @throws SQLException
* @throws IOException
*/
public void delCity(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from city where id = '"+id+"' ";
dbconn.execute(sql);
}
/**
* 根據類型列出相應的其它信息
* @param type
* @return Vector
* @throws SQLException
* @throws IOException
*/
public Vector getAllOtherInfo(String type)throws SQLException,IOException
{
Vector v = null;
String sql = "";
sql = "select * from other_info where type='"+type+"' ";
v = dbconn.ListOfMapData(sql);
return v;
}
/**
* 修改其他信息
* @param type
* @param content
* @throws SQLException
* @throws IOException
*/
public void modifyOtherInfo(String type,String content)throws SQLException,IOException
{
String sql = "";
sql = "update other_info set content = '"+content+"' where type='"+type+"' ";
dbconn.execute(sql);
}
/**
* 增加區
* @param cityId
* @param name
* @param districtNumber
* @param sort
* @throws SQLException
*/
public void addDistrict(String cityId,String name,String districtNumber,String sort) throws SQLException
{
String sql = "insert into district (cityId,districtName,districtNumber,sort,createDate) " +
"values('"+cityId+"','"+name+"','"+districtNumber+"','"+sort+"','"+StringUtil.genDateTimeString()+"')";
dbconn.execute(sql);
}
public Vector getAllDistrict() throws SQLException
{
Vector v = null;
String sql = "";
sql = "select * from district ";
sql = sql + "order by sort ";
v = dbconn.ListOfMapData(sql);
return v;
}
public void delDistrict(String id)throws SQLException,IOException
{
String sql = "";
sql = "delete from district where id = '"+id+"' ";
dbconn.execute(sql);
}
public Vector getDistrictById(String id) throws SQLException
{
Vector v = null;
String sql = "";
sql = "select * from district where id="+id;
sql = sql + " order by sort ";
System.out.println(sql);
v = dbconn.ListOfMapData(sql);
return v;
}
public Vector getDistrictByCityId(String cityId) throws SQLException
{
Vector v = null;
String sql = "";
sql = "select * from district where cityId="+cityId;
sql = sql + " order by sort ";
System.out.println(sql);
v = dbconn.ListOfMapData(sql);
return v;
}
public Vector getCityByProvinceId(String id) throws SQLException
{
Vector v = null;
String sql = "";
sql = "select * from city where provinceId="+id;
sql = sql + " order by sort ";
System.out.println(sql);
v = dbconn.ListOfMapData(sql);
return v;
}
public void modifyDistrict(String id,
String cityId,
String districtName,
String districtNumber,
String sort)throws SQLException,IOException
{
String sql = "";
sql = "update district set cityId = '"+cityId+"',districtName='"+districtName+"'," +
"districtNumber='"+districtNumber+"',sort='"+sort+"'," +
"createDate='"+StringUtil.genDateTimeString()+"' where id='"+id+"' ";
dbconn.execute(sql);
}
/**
* 生成定單
*/
public int deal(String userId,String receiveMan,String linkMan,
String address,String phone,String province,String city,String district,
String zip,String mobilePhone,String paymentType,
String carrierType,double sumPrice) throws SQLException
{
String sql = "insert into order_manager(userId,paymentType,carrierType," +
"orderDate,province,city,district,address,zip,phone,receiveMan,linkMan," +
"mobilePhone,sumPrice) values" +
"('"+userId+"','"+paymentType+"','"+carrierType+"'," +
"'"+StringUtil.genDateTimeString()+"','"+province+"','"+city+"','"+
district+"','"+address+"','"+zip+"','"+phone+"','"+receiveMan+"','"+
linkMan+"','"+mobilePhone+"','"+sumPrice+"')";
System.out.println(sql);
Statement stat = dbconn.getStatement();
stat.execute(sql);
ResultSet result = stat.getGeneratedKeys();
if(result.next())
{
System.out.println(result.getInt(1));
return result.getInt(1);
}
return 0;
}
public Vector getAllOrder(String userId) throws SQLException
{
Vector v = null;
String sql = "";
sql = "select * from order_manager where userId='"+userId+"' order by orderDate ";
v = dbconn.ListOfMapData(sql);
return v;
}
public Map getOrderById(String orderId) throws SQLException
{
Vector v = null;
String sql = "";
sql = "select * from order_manager where orderId='"+orderId+"' order by orderDate ";
v = dbconn.ListOfMapData(sql);
if(v!=null&&v.size()>0)
return (Map)v.get(0);
return null;
}
public void dealDetail(String name,String isbn,
String price,String sumPrice,String number,String orderId,String productType) throws SQLException
{
String sql = "insert into order_detail(commodityName,isbn,price,sumPrice,number,orderId,productType)"+
" values ('"+name+"','"+isbn+"','"+price+"','"+sumPrice+"','"+number+"','"
+orderId+"','"+productType+"')";
dbconn.execute(sql);
}
public Vector getOrderDetailByOrderId(String orderId) throws SQLException
{
String sql = "select * from order_detail where orderId ='" + orderId + "' ";
Vector v = dbconn.ListOfMapData(sql);
return v;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -