AssetManager.java
资源名称:OA.rar [点击查看]
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:7k
源码类别:
OA系统
开发平台:
Java
- package com.gforce.gfoa;
- import com.gforce.currency.database.*;
- import java.util.*;
- import com.gforce.currency.*;
- /**
- *
- * <p>Title: 吉力科技办公自动化系统</p>
- * <p>Description: 吉力科技办公自动化系统</p>
- * <p>Copyright: 版权所有 2003 (c) 西安吉力科技发展有限公司 Copyright (c) 2003 GForce Sceince & Technology</p>
- * <p>Company: 西安吉力科技发展有限公司 (GForce Sceince & Technology)</p>
- * @author 王江涛
- * @version 1.0
- */
- public class AssetManager
- extends RecordManager
- {
- public AssetManager()
- {
- }
- protected final static String TableName = "AssetInfo"; //定义声明本类操作表名称
- protected final static String IDFieldName = "ID"; //定义声明主键或者可以确定唯一记录的字段名称为“ID”,必须为自增整型
- protected final static String[] NumericFieldsName =
- {"AddUserID", "AssetTypeID"}; //声明数值型字段名称
- protected final static String[] StringFieldsName =
- {"AssetName","AssetNumber"}; //声明字符型字段名称
- protected final static String[] DatetimeFieldsName =
- {"AddTime"}; //声明日期时间型字段名称
- protected final static String[] TextFieldsName =
- {}; //声明大字符串型字段名称
- /**
- * 根据字段名称获取插入数据时表单元素名称
- * @param strFieldName 字段名称
- * @return 表单素名称
- */
- protected String InsertParament(String strFieldName)
- {
- return "" + strFieldName + ""; //可以根据需要加前缀、后缀
- }
- /**
- * 根据字段名称获取修改数据时表单元素名称
- * @param strFieldName 字段名称
- * @return 表单素名称
- */
- protected String UpdateParament(String strFieldName)
- {
- return "" + strFieldName + ""; //可以根据需要加前缀、后缀
- }
- /**
- * 获取本类操作表名称
- * @return 表名称
- */
- public String getTableName()
- { //获取本类操作表名称
- return TableName;
- }
- protected String getIDFieldName()
- { //获取主键或者可以确定唯一记录的字段名称
- return IDFieldName;
- }
- protected String[] getNumericFieldsName()
- { //获取数值型字段名称
- return NumericFieldsName;
- }
- protected String[] getStringFieldsName()
- { //获取字符型字段名称
- return StringFieldsName;
- }
- protected String[] getDatetimeFieldsName()
- { //获取日期时间型字段名称
- return DatetimeFieldsName;
- }
- protected String[] getTextFieldsName()
- { //获取大字符串型字段名称
- return TextFieldsName;
- }
- /**
- * 获取所有资产记录集
- * @return 所有资产记录集
- */
- public static Vector getAllRecord()
- {
- Vector vt = SQLManager.GetResultSet("Select * from " + TableName);
- return vt;
- }
- /**
- * 获取指定ID地记录
- * @param iAssetID 指定地记录ID
- * @return 记录数据集
- */
- public static Vector getByIDRecord(int iAssetID)
- {
- Vector vt = SQLManager.GetResultSet("Select * from " + TableName + " WHERE ID ='" + iAssetID +
- "'");
- return vt;
- }
- /**
- * 获取指定资产类型记录集
- * @param iAssetTypeID 资产类型ID
- * @return 指定资产类型记录集
- */
- public static Vector getByAssetTypeIDRecord(int iAssetTypeID)
- {
- return getByAssetTypeIDRecord(iAssetTypeID + "");
- }
- /**
- * 获取指定资产类型记录集
- * @param strAssetTypeIDs 资产类型ID
- * @return 指定资产类型记录集
- */
- public static Vector getByAssetTypeIDRecord(String strAssetTypeIDs)
- {
- Vector vt = SQLManager.GetResultSet("Select * from " + TableName + " WHERE AssetTypeID in(" + strAssetTypeIDs + ")");
- return vt;
- }
- /**
- * 获取指定ID的资产名称
- * @param iAssetID 资产ID
- * @return 资产名称
- */
- public static String getAssetNameByID(int iAssetID)
- {
- String strReturnValue = "未知资产";
- Vector vt = SQLManager.GetResultSet("Select AssetName from " + TableName + " where ID=" + iAssetID);
- if (vt.size() == 1)
- {
- strReturnValue = ( (Vector) vt.get(0)).get(0).toString();
- }
- return strReturnValue;
- }
- /**
- * 获取指定ID的资产编号
- * @param iAssetID 资产ID
- * @return 资产名称
- */
- public static String getAssetNumberByID(int iAssetID)
- {
- String strReturnValue = "未知编号";
- Vector vt = SQLManager.GetResultSet("Select AssetNumber from " + TableName + " where ID=" + iAssetID);
- if (vt.size() == 1)
- {
- strReturnValue = ( (Vector) vt.get(0)).get(0).toString();
- }
- return strReturnValue;
- }
- /**
- * 增加资产
- * @param m_request 增加资产的request参数
- * @return 增加资产是否成功。资产的ID(大于等于1)或者错误代码(小于1)
- */
- public int InsertRecord(Request m_request)
- {
- int iReturnValue = super.InsertRecord(m_request); //文档信息表插入数据
- int iTypesID = m_request.GetInt("TypesID");
- Vector vt = AssetFieldsManager.getByAssetTypeRecord(iTypesID);
- if (vt.size() > 0)
- {
- for (int i = 0; i < vt.size(); i++)
- {
- String strFieldType = ( (Vector) vt.get(i)).get(3).toString();
- String strFieldID = ( (Vector) vt.get(i)).get(0).toString();
- String strFieldValue = m_request.GetString("Name" + strFieldID);
- //文档字段值表插入数据
- SQLManager.ExcuteSQL("Insert AssetFieldsValue (AssetID,FieldID,FieldValue) Values (" + iReturnValue + "," + strFieldID + ",'" + strFieldValue + "')");
- }
- }
- return iReturnValue;
- }
- /**
- * 通过ID删除记录和资产得字段值
- * @param intID ID值
- * @return 错误代码,如果小于1,说明删除错误
- */
- public int DeleteByID(int intID)
- {
- AssetFieldsValueManager manager = new AssetFieldsValueManager();
- manager.DeleteBySQLWhere("AssetID = "+intID);
- return super.DeleteByID(intID);
- }
- /**
- * 资产记录地修改
- * @param m_request 页面修改地参数
- * @return 修改是否成功地值
- */
- public int UpdateRecord(Request m_request)
- {
- int iReturnValue = super.UpdateRecord(m_request); //资产信息表修改数据
- int iTypesID = m_request.GetInt("TypesID");
- Vector vt = AssetFieldsManager.getByAssetTypeRecord(iTypesID);
- if (vt.size() > 0)
- {
- for (int i = 0; i < vt.size(); i++)
- {
- String strFieldType = ( (Vector) vt.get(i)).get(3).toString();
- String strFieldID = ( (Vector) vt.get(i)).get(0).toString();
- String strFieldValue = m_request.GetString("Name" + strFieldID);
- String strAssetID = m_request.GetString("ID");
- Vector vt1 = new Vector();
- vt1 = SQLManager.GetResultSet("Select * from AssetFieldsValue where (AssetID=" + strAssetID + " and FieldID=" + strFieldID + ")");
- if (vt1.size() > 0)
- {
- SQLManager.ExcuteSQL("UPDATE AssetFieldsValue SET FieldValue='" + strFieldValue + "' where (AssetID=" + strAssetID + " and FieldID=" + strFieldID + ")");
- }
- else
- {
- SQLManager.ExcuteSQL("Insert AssetFieldsValue (AssetID,FieldID,FieldValue) Values (" + strAssetID + "," + strFieldID + ",'" + strFieldValue + "')");
- }
- }
- }
- return iReturnValue;
- }
- }