2014年7月24日 星期四

generator-checker generator-check

{object}0.66,GRN_HEADER.NO_GRN,check,0,0,GRN :No GRN,,
{/object}


document.getElementById('PRODUCT.ISCOMMERCIAL').checked = (s=='C');

2014年7月23日 星期三

java-tab


java tab remove
java enter next line remove

  1. inputString = inputString.replaceAll("\t", "");  
  2. inputString = inputString.replaceAll("\n", "");  

2014年7月22日 星期二

javascript-dtos date to string

function dateCal(pDate, pDay){
var ms = pDate.getTime(); //換成毫秒數
ms =ms+ pDay*24*60*60*1000; //計算相差的毫秒數
return new Date(ms); //返回新的時間對象
}

function dtos(pDate,pFormat){
if (!pFormat) pFormat='yyyy-mm-dd';
yyyy=pDate.getFullYear();
mm=pDate.getMonth()+1;
mm='0'+mm;
mm=right(mm,2);
dd=pDate.getDate();
dd='0'+dd;
dd=right(dd,2);
result='';
if (pFormat=='yyyy-mm-dd'){result=yyyy+'-'+mm+'-'+dd;}
else if (pFormat=='yyyymmdd'){result=yyyy+mm+dd;}
return result;
}

javascript-right



function dateCal(pDate, pDay){
var ms = pDate.getTime(); //換成毫秒數
ms =ms+ pDay*24*60*60*1000; //計算相差的毫秒數
return new Date(ms); //返回新的時間對象
}

function dtos(pDate,pFormat){
if (!pFormat) pFormat='yyyy-mm-dd';
yyyy=pDate.getFullYear();
mm=pDate.getMonth()+1;
mm='0'+mm;
mm=right(mm,2);
dd=pDate.getDate();
dd='0'+dd;
dd=right(dd,2);
result='';
if (pFormat=='yyyy-mm-dd'){result=yyyy+'-'+mm+'-'+dd;}
else if (pFormat=='yyyymmdd'){result=yyyy+mm+dd;}
return result;
}

javascript-date-calculate

http://msdn.microsoft.com/en-us/library/ie/ee532932(v=vs.94).aspx


var mydate = new Date('2014-04-03');
console.log(mydate.toDateString());

new Date('2011-04-11')
or
new Date('2011-04-11T11:51:00')

{onchange}var d=parseDate(this.value);var today=new Date(); if (d<today){alert('Remind : Purchase plan date is before today.');}{/onchange}

2014年7月21日 星期一

java-bean servlet


servlet

e.g. PDFCreateAndView.java
CompanyProfile bean = (CompanyProfile) request.getSession().getAttribute("bean");
allDocGenPDF.logoSizeFactor=bean.getLogoSizeFactor();





http://stackoverflow.com/questions/2663079/java-servlet-and-jsp-accessing-the-same-session-bean

The basic semantic tries to find an existing object using id and scope. If the object is not found it will attempt to create the object using the other attributes.
In other words,
<jsp:useBean id="user" scope="session" class="package.name.User"/>
would translate roughly into java as:
package.name.User user = (package.name.User)session.getAttribute("user");
if (user == null){
  user = new package.name.User();
  session.setAttribute("user", user);
}

2014年7月17日 星期四

mysql2java mysql to java

mysql
table to array
table2array

Connection con = null;
Statement stmt = null;
con = DriverManager.getConnection("jdbc:mysql://localhost/"+db+ "?useUnicode=true&characterEncoding=UTF8",dbID, dbPassword);
stmt = con.createStatement();

String documentLineSqlString="SELECT ITEM, MODEL , DESCRIPTION ,FORMAT(QTY,2),UNIT, FORMAT(PRICE,2), FORMAT(ROUND(PRICE*QTY,2),2) NET FROM SALES_LINE WHERE PARENT_RECORDID="+recordID+";";
String documentLineFormat="S,S,S,D,S,C,C"; // add column 1/5 step

String formats[]=documentLineFormat.split(",");
rs = stmt.executeQuery(documentLineSqlString);
while (rs.next()){
String id=rs.getString(1);
}rs.last(); //go bottom
int rowCount=rs.getRow(); //go recno
dRaws = new String[rowCount][];
String dRaws2[][] = new String[rowCount][];
rs.beforeFirst(); //go top
int iix=0;
while (rs.next()){
dRaws2[iix]=new String[7];
dRaws2[iix][2]=rs.getString(3);
dRaws2[iix][3]=rs.getString(4);
dRaws2[iix][4]=rs.getString(5);
dRaws2[iix][5]=rs.getString(6);
dRaws2[iix][6]=rs.getString(7);
iix++;
}