2016年9月30日 星期五

generator-udf generator-function




refresh('query.REASON_DESCRIPTION',uiDisplay(s.split(',')[1]));


lookupTable('SQD_FILE','SOPOQTY.SALES_ORDER',s1103x,'SQD_FILE<>"" and supplier='+s1111);

example :

{UDF1}
function afterRowColChange_(rowNumber){
var obj=document.getElementById(thisDBFName+'.IS_STATUS'+rowNumber);
if(obj){
if(document.getElementById('openApproveButton')){
var mStatus='P,Submitted';
var s0529a=(mStatus.indexOf(document.getElementById(thisDBFName+'.IS_STATUS'+rowNumber).value)>=0);
/*var s=document.getElementById(thisDBFName+'.ITEM_CONFIRM'+rowNumber).checked ;*/
var s=1;
if (s){document.getElementById('openApproveButton').disabled = !s0529a;}
}
if(document.getElementById('openEditButton')){
var mStatus='Reject,Revoked';
var s0529=(mStatus.indexOf(document.getElementById(thisDBFName+'.IS_STATUS'+rowNumber).value)<0);
document.getElementById('openEditButton').disabled = s0529;
}
}
}
{/UDF1}


2016年7月12日 星期二

read xml string data xml2value


<script>
var dataX='<resultSet>'+uiDisplay("<content recordid='146944229507925'><user_recordid>1386746903848</user_recordid><mode>request</mode><datetime>2016-07-25 18:24:55</datetime><user>lee</user><message>TEST 201607251824 AAA</message><follower_read>2016-07-25 18:25:22</follower_read></content><content recordid='146944232902265'><user_recordid>1386746903848</user_recordid><mode>reply</mode><datetime>2016-07-25 18:25:29</datetime><user>lee</user><message>ANSER DSF</message><request_read>2222016-07-25 18:25:40</request_read></content>")+'</resultSet>';


var xml = $.parseXML(dataX);
var $xml = $(xml);
$xml.find('resultSet').each(function(){
console.log(this);

$(this).children().each(function(){

alert($(this).attr("recordid")); = 146944229507925
alert($(this).text());
alert($(this).html());

  $(this).children().each(function(){alert(this.tagName+ '  '+$(this).text());});


alert($(this).children()[0].tagName);
alert($(this).children()[1].tagName);


var message_user=$(this).find('user').text();
alert(message_user);

});
});

</script>


/***************************************************/



/*
var dataX='<bookstore> <book category="cooking"> <title lang="ch">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="fa">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="web" cover="paperback"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>';
var xml = $.parseXML(dataX);
var $xml = $(xml);
$xml.find('bookstore').each(function(){
console.log(this);
$(this).children().each(function(){
console.log(this);
console.log(this.tagName);
console.log($(this).attr("category"));
var tagName=this.tagName;
var val=$(this).text();
var html=$(this).html();
console.log('Title : Language ',$(this).find('title').attr('lang'));
console.log('Title : Value ',$(this).find('title').text());
console.log('author ',$(this).find('author').text());
});
});
*/






/*********************************************/











var dataX='<bookstore> <book category="cooking"> <title lang="ch">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="fa">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="web" cover="paperback"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>';



var xml = $.parseXML(dataX);
var $xml = $(xml);
$xml.find('bookstore').each(function(){
console.log(this);
$(this).children().each(function(){
console.log(this);
console.log(this.tagName);
console.log($(this).attr("category"));
var tagName=this.tagName;
var val=$(this).text();
var html=$(this).html();
console.log('Title : Language ',$(this).find('title').attr('lang'));
console.log('Title : Value ',$(this).find('title').text());
console.log('author ',$(this).find('author').text());
});
});

2016年7月10日 星期日

iText - add content to existing PDF file insertField insert field

http://stackoverflow.com/questions/3335126/itext-add-content-to-existing-pdf-file



// Create output PDF
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();
PdfContentByte cb = writer.getDirectContent();

// Load existing PDF
PdfReader reader = new PdfReader(templateInputStream);
PdfImportedPage page = writer.getImportedPage(reader, 1); 

// Copy first page of existing PDF into output PDF
document.newPage();
cb.addTemplate(page, 0, 0);

// Add your new data / text here
// for example...
document.add(new Paragraph("my timestamp")); 

document.close();

int left=27;
int top=-10;
PdfContentByte cb = writer.getDirectContent();
FileInputStream templateInputStream= new FileInputStream("/erp/images/PrePrintForm.pdf");
PdfReader reader = new PdfReader(templateInputStream);
PdfImportedPage page = writer.getImportedPage(reader, 1);
document.newPage();
cb.addTemplate(page, left, top);
document.add(pCard.pCard());
document.add(pCard.pCardBody());


2016年6月8日 星期三

MYSQL-TABLE SIZE

SELECT 
     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;

2016年2月25日 星期四

generator-vview hview



{vView}{vViewLabel}{vViewValueStyle}
{vViewValue}{/vViewValue}
{vView}{hView}
{vViewLabel}Part No.{/vViewLabel}
{vView}
{vViewValueStyle}font-weight: bold;TEXT_IMPORTANT{/vViewValueStyle}

2016年2月24日 星期三

2016年2月7日 星期日

Graphs: Dijkstra's Algorithm ccc

https://www.youtube.com/watch?v=8Ls1RqHCOPw


http://www.cemc.uwaterloo.ca/contests/past_contests.html

java-sort


source :

http://mathbits.com/MathBits/Java/arrays/SelectionSort.htm



Array at beginning: 846976869491
After Pass #1:849176869469
After Pass #2:849194867669
After Pass #3: 869194847669
After Pass #4: 949186847669
After Pass #5 (done): 949186847669

While being an easy sort to program, the selection sort is one of the least efficient.  The algorithm offers no way to end the sort early, even if it begins with an already sorted list.  

// Selection Sort Method for Descending Orderpublic static void SelectionSort ( int [ ] num )
{
     int i, j, first, temp; 
     for ( i = num.length - 1; i > 0; i - - ) 
     {
          first = 0;  
 //initialize to subscript of first element
          for(j = 1; j <= i; j ++)   
//locate smallest element between positions 1 and i.
          {
               if( num[ j ] < num[ first ] )         
                 first = j;
          }
          temp = num[ first ];   //swap smallest found with element in position i.
          num[ first ] = num[ i ];
          num[ i ] = temp;
      }          
}

 


Programing


Java Selection

Selection Sort

Java Repetition

recursion



Graph Search Implementation graph search wiki

Scanner in = new Scanner(System.in); int next = in.nextInt();

Convert int[] into ArrayList


*****************************************
* String Array to Array List ******************
*****************************************

http://www.tutorialspoint.com/java/util/arrays_aslist.htm

Example

The following example shows the usage of java.util.Arrays.asList() method.
package com.tutorialspoint;

import java.util.Arrays;
import java.util.List;

public class ArrayDemo1 {
   public static void main (String args[]) {

   // create an array of strings
   String a[] = new String[]{"abc","klm","xyz","pqr"};
   
   List list1 = Arrays.asList(a);

   // printing the list
   System.out.println("The list is:" + list1);
   }
}
Let us compile and run the above program, this will produce the following result:
The list is:[abc, klm, xyz, pqr]


http://stackoverflow.com/questions/10530353/convert-string-array-to-arraylist



import java.util.Arrays;  
import java.util.List;  
import java.util.ArrayList;  
public class StringArrayTest  
{  
   public static void main(String[] args)  
   {  
      String[] words = {"ace", "boom", "crew", "dog", "eon"};  

      List<String> wordList = Arrays.asList(words);  

      for (String e : wordList)  
      {  
         System.out.println(e);  
      }  
   }  
}




**********************************
* Array List to string array ************
**********************************



List<String> stockList = new ArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");

String[] stockArr = new String[stockList.size()];
stockArr = stockList.toArray(stockArr);

for(String s : stockArr)
    System.out.println(s);




****************************************************************
************** Array List to Integer * *******************************
****************************************************************

http://www.tutorialspoint.com/java/util/arraylist_get.htm

Example

The following example shows the usage of java.util.ArrayList.get() method.
package com.tutorialspoint;

import java.util.ArrayList;

public class ArrayListDemo {
   public static void main(String[] args) {
      
   // create an empty array list with an initial capacity
   ArrayList<Integer> arrlist = new ArrayList<Integer>(5);

   // use add() method to add elements in the list
   arrlist.add(15);
   arrlist.add(22);
   arrlist.add(30);
   arrlist.add(40);

   // let us print all the elements available in list
   for (Integer number : arrlist) {
   System.out.println("Number = " + number);
   } 
 
   // retrieves element at 4th postion
   int retval=arrlist.get(3);
   System.out.println("Retrieved element is = " + retval);    
   }
}   
Let us compile and run the above program, this will produce the following result:
Number = 15
Number = 22
Number = 30
Number = 40
Retrieved element is = 40


***********************************************************
*  int list to int[] *********************************************
***********************************************************
https://www.blogger.com/blogger.g?blogID=5452307390516932808#editor/target=post;postID=4395252080140059040


private int[] buildIntArray(List<Integer> integers) {
    int[] ints = new int[integers.size()];
    int i = 0;
    for (Integer n : integers) {
        ints[i++] = n;
    }
    return ints;
}




http://stackoverflow.com/questions/10269300/convert-int-into-arraylist



List<Integer> list = Arrays.asList(1, 2, 3);

So something along the lines of:

int[] array = { 1, 2, 3 };
ArrayList<Integer> list = new ArrayList<Integer>(array.length);
for (int i = 0; i < array.length; i++)
  list.add(Integer.valueOf(array[i]));