⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menulistaccess.java

📁 Athena酒店小组_Athena酒店管理系统
💻 JAVA
字号:
/*
 * MenuListAccess.java
 *
 * Created on 2007年6月18日, 上午5:12
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package dennis;
import java.util.*;
import java.sql.*;

import plugin.*;
/**
 *
 * @author Administrator
 */
public class MenuListAccess {
    private IDBResource dbRes;
    /** Creates a new instance of MenuListAccess */
    public MenuListAccess(IDBResource dbRes)
    {
        this.dbRes = dbRes;
    }
    
    public int insert(MenuList menuList)
    {
	try
	{
	    Connection conn = dbRes.getConnection();
	    String sql = "INSERT INTO menuList(guestAccouts, isCheckOut) " +
		    " VALUES(?, ?)";
	    PreparedStatement ps = conn.prepareStatement(sql);
	    ps.setString(1, menuList.getGuestAccouts());
	    ps.setString(2, menuList.getIsCheckOut());
	    int rs = ps.executeUpdate();	    
	    return rs;
	}
	catch (SQLException ex)
	{
	    ex.printStackTrace();
	    return -1;
	}		
    }
    
    public int update(MenuList menuList)
    {
	try
	{
	    Connection conn = dbRes.getConnection();
	    String sql = "UPDATE menuList SET isCheckOut = ? WHERE menuId = ?";
	    PreparedStatement ps = conn.prepareStatement(sql);
	    ps.setString(1, "是");
	    ps.setInt(2, menuList.getMenuId());
	    int rs = ps.executeUpdate();	    
	    return rs;
	}
	catch (SQLException ex)
	{
	    ex.printStackTrace();
	    return -1;
	}		
    }
    
   public ArrayList<MenuList> getAllMenus()
    {
	try
	{
	    Connection conn = dbRes.getConnection();
	    String sql = "SELECT * FROM menuList";
	    PreparedStatement ps = conn.prepareStatement(sql);
	    ResultSet rs = ps.executeQuery();
	    ArrayList<MenuList> menus = new ArrayList<MenuList>();
	    while(rs.next())
	    {
		MenuList menu = new MenuList();
		menu.setMenuId(rs.getInt("menuId"));
		menu.setGuestAccouts(rs.getString("guestAccouts"));
		menu.setIsCheckOut(rs.getString("isCheckOut"));
		menus.add(menu);
	    }
	    return menus;
	}
	catch (SQLException ex)
	{
	    ex.printStackTrace();
	    return null;
	}		
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -