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

📄 pageinfoscreen.java

📁 PDA餐饮管理系统,在掌上电脑实现的,可以开台,点菜等多功能模块
💻 JAVA
字号:
package junwei;

import java.util.Vector;

import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;

import rms.*;
import item.*;

public class PageInfoScreen extends InputScreen 
implements CommandListener,ItemStateListener{
	
	private static PageInfoScreen instance;

	private TextField textMenuID;
	private  SyscodeChoice choiceBreed;
	private ShowMenuItem menuItem;
	private int tag;
	RecordEnumeration re;
	RecordStore rs;
	


	synchronized public static PageInfoScreen getInstance() {
		if (instance == null)
			instance = new PageInfoScreen();
		return instance;
	}
	
	public  PageInfoScreen() {
		super("选择菜品");
	
		textMenuID=new TextField("菜品编号:","",6,Item.PLAIN|TextField.NUMERIC);
		append(textMenuID);

		choiceBreed=new SyscodeChoice(2);
		append(choiceBreed);
	
		menuItem=new ShowMenuItem("菜品列表:",this.getWidth(),this.getHeight()-50);
		rs = RMSUtil.openRSAnymay(MainMidlet.RMS_MENU);
	
		if (rs != null) {
			try {
				re = rs.enumerateRecords(null, null, false);
				MainMidlet.menus.removeAllElements();
				while (re.hasNextElement()) {
					byte[] data = re.nextRecord();
					MainMidlet.menus.addElement(Menu.decode(data));
				}
				rs.closeRecordStore();
			} catch (Exception e) {
				System.out.println(e.toString());
			}
			
		
			sortMenus(MainMidlet.menus);
		}
		
		menuItem.setContent(MainMidlet.menus);
		append(menuItem);
		Menu aMenu=(Menu)(menuItem.getSelectContent());
		if (aMenu!=null)
		  textMenuID.setString(aMenu.getMenuId());
	    addCommand(new Command("选择", Command.OK, 1));
		addCommand(new Command("返回", Command.CANCEL, 1));
		setCommandListener(this);
		setItemStateListener(this);
	}

	public void commandAction(Command c, Displayable s) {
		if (c.getLabel().equals("选择")) {
			String menuID = textMenuID.getString();
			Menu selectMenu =MainMidlet.getMenu(menuID);

			switch (tag){
			case 1:
				if (selectMenu != null) {
					AddMenuScreen.getInstance().addMenu(selectMenu);
					showInfo("点菜:" + selectMenu.getMenuName());
				} else {
					showInfo("菜品编号不存在:" + menuID);
				}
				break;
			case 2:
				if (selectMenu != null) {
					BackMenuScreen.getInstance().setSelect(selectMenu);
					Navigator.show(null);
				} else {
					showInfo("菜品编号不存在:" + menuID);
				}
				break;
			case 3:
				if (selectMenu != null) {
					UrgenMenuScreen.getInstance().addMenu(selectMenu);
					showInfo("催菜:" + selectMenu.getMenuName());
				} else {
					showInfo("菜品编号不存在:" + menuID);
				}
				break;
			}
			
		}
		else
    		Navigator.show(null);
	}
	public void itemStateChanged(Item item) {
		if (item==menuItem){
			Menu aMenu=(Menu)(menuItem.getSelectContent());
			if (aMenu!=null)
			    textMenuID.setString(aMenu.getMenuId());
			else
				textMenuID.setString("");
		}
		else if (item==choiceBreed){
			menuItem.setContent(MainMidlet.getMenusByBreed(choiceBreed.getSelectID()));
		}
	}
	   /**
     * 设置选择类型
     * @param tag 1-点菜 2-退菜 3催菜
     */
	public void initTag(int tag){
		this.tag=tag;
		switch (this.tag){
		
		case 1: showInfo("请选择点菜菜品");

		case 2: showInfo("请选择退菜菜品");
		case 3: showInfo("请选择催菜菜品");
		}
	}
	public static void sortMenus(Vector menus){
		Menu menu_a,menu_b;
		for (int i=0;i<menus.size();i++)
			for (int j=i;j<menus.size();j++){
				menu_a=(Menu)(menus.elementAt(i));
				menu_b=(Menu)(menus.elementAt(j));
				if (Integer.parseInt(menu_a.getMenuId())>
				  Integer.parseInt(menu_b.getMenuId())){
					menus.setElementAt(menu_b,i);
					menus.setElementAt(menu_a,j);
				}
			}

}

}

⌨️ 快捷键说明

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