eas之kingdeeUtils

Posted luojiabao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eas之kingdeeUtils相关的知识,希望对你有一定的参考价值。

 

    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    
    import com.kingdee.bos.BOSException;
    import com.kingdee.bos.dao.IObjectPK;
    import com.kingdee.bos.dao.IObjectValue;
    import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
    import com.kingdee.bos.dao.query.SQLExecutorFactory;
    import com.kingdee.bos.framework.DynamicObjectFactory;
    import com.kingdee.bos.util.BOSObjectType;
    import com.kingdee.bos.util.BOSUuid;
    import com.kingdee.eas.tools.datatask.client.TemplateExport;
    import com.kingdee.jdbc.rowset.IRowSet;
    import com.kingdee.util.UuidException;
 
    /**
     * 常用金蝶工具类
     * @author luojiabao
     *
     */
    public class KingdeeUtils
        /**
         * 执行SQL语句,对象装载为list
         * @throws BOSException
         * @throws SQLException
         */
        public static List<Object[]> executeSQL(String sql) throws BOSException, SQLException
            List<Object[]> values=new ArrayList<Object[]>();
            IRowSet rs=SQLExecutorFactory.getRemoteInstance(sql).executeSQL();
            ResultSetMetaData rsmd=rs.getMetaData();
            while (rs.next())
                int count=rsmd.getColumnCount();
                Object[] objs=new Object[count];
                for (int i = 1; i < count; i++)
                    objs[i-1]=rs.getObject(i);
                
                values.add(objs);
            
            return values;
        
        /**
         * 返回一个数据
         * @param sql
         * @return
         * @throws SQLException
         * @throws BOSException
         */
        public static Object returnOneData(String sql) throws BOSException, SQLException
            if(sql!=null&&!sql.equals(""))
                List<Object[]> list=executeSQL(sql);
                if(list.size()>0)
                    return list.get(0)[0];
                else
                    return null;
                
            
            return sql;
        
    
    /**
     * 动态获取Info对象
     * @throws BOSException
     */
    public static IObjectValue getInfo(String id) throws BOSException
        IObjectValue objValue=null;
        if(id!=null && !"".equals(id))
            BOSUuid uuid=BOSUuid.read(id);
            IObjectPK pk = new ObjectUuidPK(uuid);
            objValue=DynamicObjectFactory.getRemoteInstance().getValue(uuid.getType(),pk);
        
        return objValue;
    
    
    /**
     * 动态单据操作-->删除
     * @param id
     * @return
     * @throws BOSException
     */
    public static boolean delete(String id)
        try
            BOSUuid uuid=BOSUuid.read(id);
            DynamicObjectFactory.getRemoteInstance().delete(uuid.getType(),new ObjectUuidPK(uuid));
            return true;
         catch (UuidException e)
            // TODO Auto-generated catch block
            e.printStackTrace();
         catch (BOSException e)
            // TODO Auto-generated catch block
            e.printStackTrace();
        
        return false;
    
    
    /**
     * 动态单据操作 新增
     * @param bosType
     * @param objValue
     * @return
     */
    public static boolean addNew(BOSObjectType bosType,IObjectValue objValue)
        try
            DynamicObjectFactory.getRemoteInstance().addnew(bosType, objValue);
            return true;
         catch (BOSException e)
            // TODO Auto-generated catch block
            e.printStackTrace();
        
        return false;
    
    
    /**
     * 动态单据操作 更新
     * @param id
     * @param objectValue
     * @return
     */
    public static boolean update(String id,IObjectValue objectValue)
        BOSUuid uuid=BOSUuid.read(id);
        IObjectPK pk=new ObjectUuidPK(uuid);
        try
            DynamicObjectFactory.getRemoteInstance().update(uuid.getType(),pk,objectValue);
            return true;
         catch (BOSException e)
            // TODO Auto-generated catch block
            e.printStackTrace();
        
        return false;    
    
    
    /**
     * 导出模板
     * @param number
     * @param sheet
     * @param path
     * @return
     */
    public static boolean templateExport(String number,String sheet,String path)
        try
            TemplateExport te=new TemplateExport(number,sheet);
            te.export();
            return true;
         catch (Exception e)
            e.printStackTrace();
        
        return false;
    
    
 

以上是关于eas之kingdeeUtils的主要内容,如果未能解决你的问题,请参考以下文章

eas之kingdeeUtils

eas之KDPrinter控件

eas之action的创建

EAS开发之挂菜单

eas之控制kdtable滚动条

UML数据建模工具之Enterprise Architect(EA)实例