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

📄 activationitem.java

📁 java swing源码 欢迎下载 有问题请联系 我一定负责到底
💻 JAVA
字号:
/**
 * 卡式保单激活配置项
 */
package com.NCL;

import java.util.*;
import com.sinosoft.common.DBAccess;
import com.sinosoft.common.Data;
import com.sinosoft.common.IndexMap;

public class ActivationItem {
	protected IndexMap propList;
	protected HashSet Property;
	private List strList = new ArrayList();
	private boolean EOF = false;
	private int COUNT;
	/**
	 * 构造函数
	 *
	 */
	public ActivationItem(){
		propList = new IndexMap();
		Property = new HashSet();
		Property.add("ID");
		Property.add("ProductID");//产品代码
		Property.add("ItemType");//配置项类型(被保险人配置项、连带被保险人类型配置项、连带被保险人配置项)
		Property.add("ItemName");//配置项名称
		Property.add("IsRequired");//是否必填项(对于连带类型则表示其对应的代码,如:01,02,03,04,05,06)
	}
	/**
	 * 初始化
	 * @param activationItemID  产品激活项ID
	 * 
	 */
	public void init(String activationItemID){
		DBAccess d  = new DBAccess();    
		String sql = "SELECT * from ActivationItem where ID=?";
		this.propList = d.init(sql,activationItemID,this.Property);		
	}
	/**
	 * 创建激活配置项
	 * 
	 * @return boolean
	 */
	public boolean createActivationItem(){
		String sql = "INSERT into ActivationItem values (ACTIVATIONITEMID_SQE.nextval,?,?,?,?)";
		DBAccess d  = new DBAccess();
		return d.execute(sql,this.propList);
	}
	/**
	 * 批量新增激活配置项
	 * @param l 数组对象
	 * @return boolean
	 */
	public boolean mulCreateActivationItem(List l){
		String sql = "INSERT into ActivationItem values (ACTIVATIONITEMID_SQE.nextval,?,?,?,?)";
		DBAccess d  = new DBAccess();
		return d.mulExecute(sql,l);
	}
	/**
	 * 删除激活配置项
	 * @param activationItemID
	 * @return boolean
	 */	
	public boolean deleteActivationItem(String activationItemID){
		DBAccess DBA= new DBAccess();
		String SQL = "DELETE from ActivationItem WHERE ID=?";		
		return DBA.executeDelete(SQL,activationItemID);
	}
	/**
	 * 批量删除激活配置项
	 * @param l 数组对象
	 * @return boolean
	 */
	public boolean mulDeleteActivationItem(List l){
		DBAccess DBA= new DBAccess();
		String SQL = "DELETE from ActivationItem WHERE ID=?";		
		return DBA.mulExecute(SQL,l);
	}
	/**
	 * 查询激活配置项
	 * @param at  激活项配置对象
	 * @param pageSize 显示行数
	 * @param pageIndex 页码
	 * @return String
	 */
	public String findActivationItem(ActivationItem at,int pageSize,int pageIndex){
		String result = "";
		StringBuffer SQL = new StringBuffer("SELECT ID from ActivationItem where 1=1");
		String productID = at.get("ProductID");  //获得页面参数值
		String itemType = at.get("ItemType");
		String itemName = at.get("ItemName");
		if(Data.hasValue(productID))
			SQL.append(" and ProductID=?");   //将条件拼入SQL中
		if(Data.hasValue(itemType))
			SQL.append(" and ItemType like ?");
		if(Data.hasValue(itemName))
			SQL.append(" and ItemName=?");
		DBAccess d  = new DBAccess();
		result = d.executeQuery(SQL.toString(),at.propList,pageSize,pageIndex);
		setCOUNT(d.COUNT);
		setEOF(d.EOF);
		return result;				
	}
	/**
	 * 查询必填的配置项
	 * @param productID
	 * @param itemType
	 * @return
	 */
	public HashMap getSelectedItems(String productID,String itemType){
		HashMap hm = new HashMap();
		this.set("ProductID",productID);
		this.set("ItemType",itemType);
		String result = this.findActivationItem(this,0,1);
		if(result != null && !"".equals(result)){
			String[] itemIDs = result.split(",");
			for(int i = 0; i < itemIDs.length; i ++){
				this.init(itemIDs[i]);
				hm.put(this.get("ItemName"),this.get("IsRequired"));
				this.clear();
			}
		}
		return hm;		
	}
	/**
	 * 查询连带被保险人类型配置项
	 * @param productID
	 * @return
	 */
	public String makeRInsurantTypeOption(String productID){
		StringBuffer options = new StringBuffer("");
		this.set("ProductID",productID);
		this.set("ItemType","连带被保险人类型配置项");
		String result = this.findActivationItem(this,0,1);
		if(result != null && !"".equals(result)){
			String itemIDs[] = result.split(",");
			for(int i = 0; i < itemIDs.length; i++){
				this.init(itemIDs[i]);
				options.append("<option value="+ this.get("IsRequired") +">"+this.get("ItemName")+"</option>");
			}
		}		
		return options.toString();
	}
	/**
	 * 根据itemType查询配置项
	 * @param productID
	 * @param itemType
	 * @return
	 */
	public String makeActivationItems(String productID,String itemType){
		StringBuffer items = new StringBuffer("<tr>");
		this.set("ProductID",productID);
		this.set("ItemType",itemType);
		String result = this.findActivationItem(this,0,1);
		//HashSet hs = new HashSet();
		HashMap hm = new HashMap();
		if(result != null && !"".equals(result)){
			String[] checkedItems = result.split(",");
			for(int i = 0; i < checkedItems.length; i++){
				this.init(checkedItems[i]);
				hm.put(this.get("ItemName"),this.get("IsRequired"));
				this.clear();
			}
		}
		String typeName = "";
		String requiredTypeName = "";
		String strAllItems = "";
		boolean bl = false;
		if("被保险人配置项".equals(itemType)){
			typeName = "InsurantItem";
			requiredTypeName = "Insurant";
			strAllItems = "姓名,性别,证件类型,证件号码,出生日期,联系电话,联系地址,电子邮件,职业类别,职业编码";
		}else if("连带被保险人类型配置项".equals(itemType)){
			typeName = "RelatedInsurantType";
			strAllItems = "父亲,母亲,丈夫,妻子,儿子,女儿";
			bl = true;
		}else if("连带被保险人配置项".equals(itemType)){
			typeName = "RelatedInsurant";
			requiredTypeName = "RelatedInsurant";
			strAllItems = "姓名,性别,证件类型,证件号码,出生日期,联系电话,联系地址,职业类别,职业编码";
		}
		String[] allItems = strAllItems.split(",");
		String event="";
		String checkStatus = "";
		for(int i = 0; i < allItems.length; i++){
			//----------
			if("职业编码".equals(allItems[i])){
			 event="onclick=\"levelCheck();\"";
			}else{
				event="";
			}
			//-----------
			if(hm != null && hm.containsKey(allItems[i])){
				checkStatus = "checked";
			}else{
				checkStatus = "";
			}
			items.append("<td width=90>");
			items.append("<input type=checkbox name=\""+typeName+"\" value=\""+allItems[i]+"\" "+event+" "+checkStatus+">"+allItems[i]);
			items.append("</td>");
			int enterNo = 4;//换行标志
			if(!bl){//不是配置连带被保险人类型
				enterNo = 2;
				String requiredStatus = "";
				if(hm != null && "1".equals(hm.get(allItems[i]))){
					requiredStatus = "checked";
				}else{
					requiredStatus = "";
				}
				items.append("<td width=90>");
				items.append("必填:<input type=checkbox name=\"" + requiredTypeName + allItems[i] + "\" value=\"1\" " + requiredStatus + ">");			
				items.append("</td>");				
			}
			if((i+1) % enterNo == 0){
				items.append("</tr><tr>");
			}
		}
		items.append("</tr>");
		return items.toString();
	}
	/**
	 * 更新或者删除配置项
	 * @param at 对象
	 * @param operate 操作类型:update-更新 delete-删除
	 * @return boolean
	 */
	public boolean doEdit(ActivationItem at,String operate){
		 boolean bl = false;
		 if("update".equals(operate)){
			 bl = at.updateActivationItem();
		 }else if("delete".equals(operate)){
			 bl = at.deleteActivationItem(at.get("ID"));
		 }
		 return bl;
	 }
	/**
	 * 更新配置项
	 * @return boolean
	 */
	public boolean updateActivationItem(){
		try{
			StringBuffer sql = new StringBuffer("update ActivationItem 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("ActivationItem.updateActivationItem():" + e.getMessage());
			return false;
		}
	}
	/**
	 * 在此映射中关联指定值与指定键
	 * @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();
	}
	
	public static void main(String []ages){
	}
}

⌨️ 快捷键说明

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