/**
* 通过fid获取表名 * @param fid
* @return 表名 */
public static String getDBTableName(String fid){ String Tablename = \
com.kingdee.bos.util.BOSObjectType bosType = BOSUuid.read(fid).getType(); try {
Tablename
FMIsqlFacadeFactory.getRemoteInstance().getTableNameByBosType(bosType); } catch (BOSException e) {
alert2(\获取表名出错\ }
return Tablename; }
/**
* 执行SQL(查询,返回集合) * @param sql * @return
IRowSet rs = UtilClass.executeQuery(sql.toString()); while(rs.next()){
rs.getObject(1).toString(); } */
public static IRowSet executeQuery(String sql){ IRowSet returnvalue = null; try {
IFMIsqlFacade db
com.kingdee.eas.fm.common.FMIsqlFacadeFactory.getRemoteInstance(); returnvalue = db.executeQuery(\ } catch (Exception e) {
alert2(\执行SQL出错\ }
return returnvalue; } /**
* 执行SQL(查询,返回单看值) * @param sql * @return String */
public static String executeQueryString(String sql){
=
=
String returnvalue = null; try {
IFMIsqlFacade db
com.kingdee.eas.fm.common.FMIsqlFacadeFactory.getRemoteInstance(); IRowSet rs = db.executeQuery(\ while(rs.next()){
if(rs.getObject(1)!=null){
returnvalue = rs.getObject(1).toString(); } }
} catch (Exception e) {
alert2(\执行SQL出错\ }
return returnvalue; } /**
* 执行SQL(新增,修改) * @param sql */
public static void executeSql(String sql){ try {
IFMIsqlFacade db
com.kingdee.eas.fm.common.FMIsqlFacadeFactory.getRemoteInstance(); db.executeSql(\ } catch (Exception e) { alert2(\执行SQL出错\ } }
/**
* SQL数据导出到Excel文件 * @param sql
* @param FileName 文件名 */
public static String SQLExpot(String sql,String FileName){ String returnvalue =\ try {
if(\ return returnvalue; }
if(FileName==null||\ FileName = \ }
String Filepath = UtilClass.OpenPathSelect();
=
=
String File = \
if(\ return returnvalue; }else{
File = Filepath+\ }
File file = new File(File);
//如果找到相同的文件,执行删除 if(file.exists() && file.isFile()){ file.delete(); }
WritableWorkbook wwb = Workbook.createWorkbook(new File(File)); //创建工作表
wwb.createSheet(\ //获取工作表
WritableSheet ws = wwb.getSheet(0);
//表头行样式
WritableCellFormat TableHead = new WritableCellFormat(); TableHead.setBorder(Border.ALL, BorderLineStyle.THIN); TableHead.setAlignment(Alignment.CENTRE); TableHead.setBackground(Colour.GRAY_25);
//表体数据行样式
WritableCellFormat TableRow = new WritableCellFormat(); TableRow.setAlignment(Alignment.CENTRE);
IRowSet rs = UtilClass.executeQuery(sql); //生成列名
for(int i=0;i String columnName = rs.getRowSetMetaData().getColumnName(i+1); ws.addCell(new Label(i,0,columnName,TableHead)); } int z=1; while(rs.next()){ for(int j=1;j<=rs.getRowSetMetaData().getColumnCount();j++){ if(rs.getObject(j)!=null){ ws.addCell(new Label(j-1,z,rs.getObject(j).toString(),TableRow)); } } z++; } wwb.write(); wwb.close(); } catch (Exception e) { alert2(\导出数据生成Excel文件出错\ } return returnvalue; } /** * 集装箱箱号正确性验证 * @param BoxNum 箱号 * @return Boolean if(!UtilClass.BoxVerification(boxnum)){ if(!UtilClass.alertReturn(\箱号:\不是国际标准箱号,是否保存?\ UtilClass.Stop(); } } */ public static boolean BoxVerification(String BoxNum){ HashMap bj = new HashMap(); bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ bj.put(\ //去掉箱号两边空格 String newBoxNum = BoxNum.trim(); //判断箱号是否为国际标准11位 if(newBoxNum.length() != 11){ return false; } //判断前四位为字母 區別小寫 for(int i=0;i<4;i++){ String Nums = newBoxNum.substring(i, i+1); char chs[] = Nums.toCharArray(); if((int)chs[0]<65 || (int)chs[0]>90){ return false; } } //判断后7位为数字 for(int i=4;i<11;i++){ String Nums = newBoxNum.substring(i, i+1); char chs[] = Nums.toCharArray(); if((int)chs[0]<48 || (int)chs[0]>57){ return false; } } //判断第11数验证码是否正确 double VerificationNumSum = 0; for(int i=0;i<10;i++){ //获取当前位字母或数字对应的数值 double bjdata = ((Integer)bj.get(newBoxNum.substring(i, i+1))).doubleValue(); //获取当前位对应的2的i次方 double jfdata = Math.pow(2,i); 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库BOS笔记(5)在线全文阅读。
相关推荐: