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

📄 menumanagedao.java

📁 使用Eclipse开发的基于struts的银行信用管理网站
💻 JAVA
字号:
package com.webwork.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.webwork.struts.form.MenuInfoForm;
import com.webwork.struts.form.RoleInfoForm;
import com.webwork.dataSource.*;
/**
 * 
 * @author keyu_Scott
 *
 */
public class MenuManageDao {
	public ArrayList QueryMenu(MenuInfoForm menuInfo)
	{
        //---------------------------变量申明---------------------------------------
		Connection connt = null;
		Statement stmt = null;
		ResultSet rs = null;
		ArrayList list = new ArrayList();
		
		//------------------Sql语句拼接-----------------------------------------
		String sql = CreateQuerySQL(menuInfo);
		try {
			connt = MySqlSource.getConnection();
			stmt = connt.createStatement();
			rs = stmt.executeQuery(sql);
			
			while(rs.next())
			{
				MenuInfoForm menu = new MenuInfoForm();
				menu.setMenuid(rs.getString("MENUID"));
				menu.setMenucode(rs.getString("MENUCODE"));
				menu.setMenuLevel(rs.getString("MENULEVEL"));
				menu.setMenuLink(rs.getString("MENULINK"));
				menu.setMenuname(rs.getString("MENUNAME"));
				menu.setMenuShow(rs.getString("MENUSHOW"));
				menu.setMenuState(rs.getString("MENUSTATE"));
				menu.setMenuType(rs.getString("MENUTYPE"));
				menu.setUpMenucode(rs.getString("UPMENUCODE"));
				list.add(menu);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return list;
	}
	public int InsertMenu(MenuInfoForm menuInfo)
	{
		
		return 0;
	}
	public int EditMenu(MenuInfoForm menuInfo)
	{
		return 0;
	}
	private String CreateQuerySQL(MenuInfoForm menuInfo)
	{
		String sql = "";
		if(!menuInfo.getMenucode().equals(""))
	    {
	    	if(sql.equals(""))
	    	{
	    		sql = " MENUCODE = '" +menuInfo.getMenucode()+ "'";
	    	}
	    	else
	    	{
	    		sql = sql+" and MENUCODE = '" +menuInfo.getMenucode()+ "'";
	    	}
	    }
	    if(!menuInfo.getMenuname().equals(""))
	    {
	    	if(sql.equals(""))
	    	{
	    		sql = " MENUNAME = '" +menuInfo.getMenuname()+ "'";
	    	}
	    	else
	    	{
	    		sql = sql+" and MENUNAME = '" +menuInfo.getMenuname()+ "'";
	    	}
	    }
	    if(!menuInfo.getMenuState().equals(""))
	    {
	    	if(sql.equals(""))
	    	{
	    		sql = " MENUSTATE = '" + menuInfo.getMenuState()+ "'";
	    	}
	    	else
	    	{
	    		sql = sql+" and MENUSTATE = '" +menuInfo.getMenuState()+ "'";
	    	}
	    }
	    if(sql.equals(""))
		{
			sql = "select * from MENU";
		}
		else
			sql = "select * from MENU where " + sql;
	    return sql;
	}
}

⌨️ 快捷键说明

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