📄 nosherydao.java
字号:
package com.noshery.dao;
import com.food.form.Food;
import com.foodset.form.FoodSet;
import java.sql.*;
import java.util.*;
import com.common.*;
import com.util.*;
public class nosheryDao
{
public nosheryDao()
{
}
public java.util.ArrayList getWeekFoodList(String storeID,String weekNo)
{
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = "select * from foodset where storeID='"+storeID+"' AND weekNum='"+weekNo+"'";
java.util.ArrayList weekFoodList = new java.util.ArrayList();
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(strSQL);
FoodSet set = null;
while (rs.next())
{
set = new FoodSet();
set.setFoodsetID(rs.getString("foodsetID"));
set.setAlias(rs.getString("alias"));
set.setFoodList(rs.getString("foodList"));
set.setPrice(rs.getFloat("price"));
set.setDescript(rs.getString("descript"));
set.setWeekNum(rs.getString("weekNum"));
set.setWeekday(rs.getString("weekday"));
set.setFoodImage(rs.getString("foodImage"));
set.setStoreID(rs.getString("storeID"));
weekFoodList.add(set);
}
}
catch (Exception exception)
{
exception.printStackTrace();
System.out.print(strSQL);
}
finally { try { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (conn != null) dbc.closeDBConnection(conn); } catch (SQLException e) {}}
return weekFoodList;
}
public java.util.ArrayList getAnyFoodList(String storeID,String foodType)
{
java.util.ArrayList anyFoodList = new java.util.ArrayList();
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = " SELECT * FROM Food where storeID='"+storeID+"' AND foodType='"+foodType+"'";
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(strSQL);
Food model = null;
while (rs.next())
{
model = new Food();
model.setFoodID(rs.getString("foodID"));
model.setFoodName(rs.getString("foodName"));
model.setFoodType(rs.getString("foodType"));
model.setBigPrice(rs.getFloat("bigPrice"));
model.setSmallPrice(rs.getFloat("smallPrice"));
model.setSnackPrice(rs.getFloat("snackPrice"));
model.setDescript(rs.getString("descript"));
model.setFoodImage(rs.getString("foodImage"));
model.setCreateDate(rs.getString("createDate"));
model.setModifyDate(rs.getString("modifyDate"));
model.setFoodClass(rs.getString("foodClass"));
model.setStoreID(rs.getString("storeID"));
anyFoodList.add(model);
}
}
catch (Exception exception)
{
exception.printStackTrace();
System.out.print(strSQL);
}
finally { try { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (conn != null) dbc.closeDBConnection(conn); } catch (SQLException e) {}}
return anyFoodList;
}
public java.util.ArrayList getFoodType(String storeID)
{
DBConnection dbc = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = "select distinct foodType from food where storeID='"+storeID+"'" ;
java.util.ArrayList weekFoodList = new java.util.ArrayList();
try
{
dbc = new DBConnection();
conn = dbc.getDBConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(strSQL);
while (rs.next())
{
weekFoodList.add(rs.getString(1));
}
}
catch (Exception exception)
{
exception.printStackTrace();
System.out.print(strSQL);
}
finally { try { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (conn != null) dbc.closeDBConnection(conn); } catch (SQLException e) {}}
return weekFoodList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -