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

📄 articleattmanager.java

📁 一个完整的
💻 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 ArticleAttManager
    extends RecordManager {
    public ArticleAttManager() {
    }

    protected final static String TableName = "ArticleAttInfo"; //定义声明本类操作表名称
    protected final static String IDFieldName = "ID"; //定义声明主键或者可以确定唯一记录的字段名称为“ID”,必须为自增整型
    protected final static String[] NumericFieldsName = {"FartherID"}; //声明数值型字段名称
    protected final static String[] StringFieldsName = {"AttName","AttURL","FartherTable"}; //声明字符型字段名称
    protected final static String[] DatetimeFieldsName = {}; //声明日期时间型字段名称
    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;
    }

		/**
		 * 获取指定MessageID的附件列表
		 * @param iMessageID 短信息标识
		 * @return 指定MessageID的附件列表向量集
		 */
		public static Vector getAttInfo(int iRecordID,String strFarther)
		{
			String strSQL = "SELECT * FROM " + TableName + " where FartherID=" + iRecordID + " and FartherTable='" + strFarther + "'";
			Vector vt = SQLManager.GetResultSet(strSQL);
			return vt;
		}

			/**
         *
					* @param iFartherID
					* @param strFartherTable
					* @param strAccessoriesNames
					* @param strAccessoriesURLs
					* @return
					*/
		public static int InsertArticle(int iFartherID,String strFartherTable,String strAccessoriesNames,String strAccessoriesURLs)
		{
				try
				{
					if(strAccessoriesURLs.length()>0)
					{
						String[] strAccessoriesURL = strAccessoriesURLs.split(",");
						String[] strAccessoriesName = strAccessoriesNames.split(",");
						for (int j = 0; j < strAccessoriesURL.length; j++)
						{
							if (strAccessoriesURL[j].trim().length() > 0)
							{
								if (AddAttment(iFartherID, strAccessoriesName[j], strAccessoriesURL[j].trim(), strFartherTable) <= 0)
								{
									SystemOut.ErrOut("新增附件时出错!附加名称:" + strAccessoriesName[j].trim() + "");
								}
							}
						}
					}
				}
				catch (Exception e)
				{
					SystemOut.ErrOut("新增附件时出错!");
				}
				return 1;
		}

			/**
			 * 新增短信息附件
			 * @param iMsgID  短信息唯一标识ID
			 * @param strAttURL  短信息附件URL
			 * @return  附件ID或者错误代码
			 */
			private static int AddAttment(int iMsgID, String strAttURL, String FartherTable)
			{
				String strAttName = strAttURL.substring(strAttURL.lastIndexOf("/") + 1);
				return AddAttment(iMsgID, strAttName, strAttURL,FartherTable);
			}


				/**
				 * 新增短信息附件
				 * @param iMsgID  短信息唯一标识ID
				 * @param strAttName  短信息附件名称
				 * @param strAttURL  短信息附件URL
				 * @return  附件ID或者错误代码
				 */
				private static int AddAttment(int iMsgID, String strAttName, String strAttURL, String FartherTable)
				{
					int iAttmentID = 0;
					String strSQLInsert = "Insert into ArticleAttInfo (AttName,AttURL,FartherID,FartherTable) values ('" + strAttName
						+ "','" + strAttURL + "'," + iMsgID + ",'" + FartherTable + "')";
					iAttmentID = SQLManager.ExcuteSQL(strSQLInsert);
					if (iAttmentID > 0)
					{
						String strSQLSelect = "select max(ID) from ArticleAttInfo where AttName='" + strAttName + "' and AttURL='"
							+ strAttURL + "' and  FartherID=" + iMsgID + " and FartherTable='" + FartherTable + "'";
						Vector vt = SQLManager.GetResultSet(strSQLSelect);
						if (vt.size() == 1)
						{
							return Integer.parseInt( ( (Vector) vt.get(0)).get(0).toString());
						}
						else
						{
							return -2; //表示新插入的记录不存在,新记录插入没有成功
						}
					}
					else
					{
						return iAttmentID;
					}
				}

					/**
					    *删除制定的附件记录。
							* @param iFartherID 指定的附件的FartherID
							* @param strFartherTable 指定的附件的FartherTable。
							*/

					 public static void DelArticleByIDs(int iFartherID, String strFartherTable)
					 {

						String strSQLString = "Delete from ArticleAttInfo where (FartherID = " + iFartherID + ")and (FartherTable='"
							 + strFartherTable + "')";
						 SQLManager.ExcuteSQL(strSQLString);
					 }

}

⌨️ 快捷键说明

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