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

📄 honor.java

📁 java swing源码 欢迎下载 有问题请联系 我一定负责到底
💻 JAVA
字号:
/**
 * 荣誉
 */
package com.NCL;

import com.sinosoft.common.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import com.sinosoft.common.DBAccess;

public class Honor {
	protected IndexMap propList;	
	protected HashSet Property;
	private List strList = new ArrayList();
	private boolean EOF = false;
	private int COUNT;
	/**
	 * 构造函数
	 *
	 */
	public Honor(){
		propList = new IndexMap();
		Property = new HashSet();
		Property.add("ID");				//ID
		Property.add("AgentID");		//代理人号
		Property.add("HonorDate");		//获得时间
		Property.add("HonorTitle");		//荣誉标题
		Property.add("HonorDetail");	//荣誉明细
		Property.add("LastModified");	//最后一次修改时间
	}
	/**
	 * 初始化
	 * @param id ID
	 */
	public void init(String id){
		DBAccess d  = new DBAccess();
		String sql = "SELECT * from Honor where ID=?";
		this.propList = d.init(sql,id,this.Property);		
	}
	/**
	 * 创建
	 * @return boolean
	 */
	public boolean createHonor(){
		String sql = "INSERT into Honor(ID,AgentID,HonorDate,HonorTitle,HonorDetail,LastModified) " 
					 + "values(HonorID_SQE.nextval,?,?,?,?,sysdate)";
		DBAccess d  = new DBAccess();
		return d.execute(sql,this.propList);
	}
	/**
	 * 更新
	 * @return boolean
	 */
	public boolean updateHonor(){
		try{
			StringBuffer sql = new StringBuffer("update Honor set ");
			List l = new ArrayList();
			for(int i=0;i<strList.size();i++){
				Object[] strArray =(Object[]) strList.get(i);
				sql.append(strArray[0]);
				sql.append("=?,");
				l.add(strArray[1]);
			}
			sql.deleteCharAt(sql.lastIndexOf(","));
			sql.append(" where ID=?");
			l.add(this.get("ID"));
			strList.clear();
			DBAccess q = new DBAccess();
			return q.executeUpdate(sql.toString(),l);
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("Honor.updateHonor():" + e.getMessage());
			return false;
		}
	}
	/**
	 * 删除
	 * @param id ID
	 * @return boolean
	 */
	public boolean deleteHonor(String id){
		DBAccess DBA= new DBAccess();
		String SQL = "DELETE from Honor WHERE ID=?";		
		return DBA.executeDelete(SQL,id);
	}
	/**
	 * 根据代理人号查询ID
	 * @param agentID 代理人号
	 * @return String
	 */
	public String findHonorByAgentID(String agentID){
		String SQL = "SELECT ID from Honor where AgentID=?";
		this.set("AgentID", agentID);
		DBAccess DBA = new DBAccess();		
		String result = DBA.executeQuery(SQL,propList,0,1);
		return result;	
	}
	/**
	 * 根据类型进行操作
	 * @param we		对象
	 * @param operate	类型
	 * @return boolean
	 */
	public boolean doEdit(Honor we,String operate){
		boolean bl = false;
		if("create".equals(operate)){
			bl = this.createHonor();
		}else if("update".equals(operate)){
			bl = this.updateHonor();
		}else if("delete".equals(operate)){
			bl = this.deleteHonor(we.get("ID"));
		}
		return bl;
	}

	/**
	 * 在此映射中关联指定值与指定键
	 * @param name 指定键
	 * @param value 指定值
	 */
	public void setUpdateValue(String name,Object value){
		if(this.set(name,value)){
			Object[] uValue = new Object[2];
			uValue[0] = name;
			uValue[1] = value;
			strList.add(uValue);
		}
	}
	/**
	 * 在此映射中关联指定值与指定键
	 * @param name 指定键
	 * @param value 指定值
	 */
	public boolean set(String name, Object value){
		if(Property.contains(name)){
			propList.put(name,value);
			return true;
		}else
			return false;		
	}
	/**
	 * 返回指定键在此映射中所映射的值
	 * @param name 指定键
	 * @return
	 */
	public String get(String name){
		if (Property.contains(name)){
			String value = (String)propList.get(name);
			if(value != null && !value.equals(""))
				return value;
			else
				return "";
		}else 
			return "";
	}
	/**
	 * 返回COUNT
	 * @return int
	 */
	public int getCOUNT() {
		return COUNT;
	}
	/**
	 * 设置COUNT
	 * @param count
	 */
	public void setCOUNT(int count) {
		COUNT = count;
	}
	/**
	 * 返回EOF
	 * @return boolean
	 */
	public boolean isEOF() {
		return EOF;
	}
	/**
	 * 设置EOF
	 * @param eof
	 */
	public void setEOF(boolean eof) {
		EOF = eof;
	}
	/**
	 * 清空propList
	 *
	 */
	public void clear(){
		propList.clear();
	}
}

⌨️ 快捷键说明

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