หน้าเว็บ

วันพุธที่ 5 ตุลาคม พ.ศ. 2554

Ubuntu : ติดตั้ง Webmin

1. Download โปรแกรม

หรือ
  1. wget http://192.168.0.252/webmin-1.560_all.deb


2.ติดตั้งด้วยคำสั่ง
  1. dpkg -i webmin-1.570_all.deb


3.ถ้าขาด package บางอย่าง ต้องลงเพิ่มด้วยคำสั่ง
  1. apt-get install -f


4.เรียกใช้งานได้จาก https://hostname:10000 (login ด้วย user ที่ sudo ได้)
เ่ช่น https://localhost:10000

วันพุธที่ 28 กันยายน พ.ศ. 2554

VB.Net : Button DaialogBox Select File

Code
First you add ToolBox openfileDialog and set name.
example name is OpenFileDialog

Insert code in Button Click.
  1.    Private Sub Button_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Browse.Click
  2.         Dim PicturePath As String
  3.         OpenFileDialog.InitialDirectory = "C:\"
  4.         OpenFileDialog.Title = "Select Image File"
  5.         OpenFileDialog.Filter = "ไฟล์ภาพ (*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp"
  6.         OpenFileDialog.ShowDialog()
  7.  
  8.         PicturePath = OpenFileDialog.FileName
  9.         'If Trim(PicturePath) = "" Or Len(PicturePath) = 0 Then Exit Sub
  10.         TextBox_URL.Text = PicturePath
  11.         'ให้ image1 แสดงผลภาพ
  12.         'Image1.Picture = LoadPicture(PicturePath)
  13.         Button_Clear.Enabled = True
  14.     End Sub

VB.Net : Copy file to new path.

First step Import System.IO.File on top code.

and use code in button.
  1.  
  2. Dim FileToCopy As String
  3. Dim NewCopy As String
  4.  
  5. FileToCopy = "C:\Users\Owner\Documents\test.txt"  'Old path
  6. NewCopy = "C:\Users\Owner\Documents\NewTest.txt"  'New path
  7.  
  8. If System.IO.File.Exists(FileToCopy) = True Then
  9. System.IO.File.Copy(FileToCopy, NewCopy) ' copy วางทับชื่อซ้ำไม่ได้
  10. 'System.IO.File.Copy(FileToCopy, NewCopy, True) 'copy วางและแทนที่
  11. MsgBox("File Copied")
  12. End If


example :

  1.    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.         Dim FileToCopy As String
  3.         Dim NewCopy As String
  4.         Dim NameImage As String
  5.  
  6.         FileToCopy = TextBox_URL.Text 'name of text save url.
  7.         NewCopy = "\\server3\7C งทส\00-อื่น ๆ\Personal Data\สุวิทย์  จำปาหอม\ImageAMS\1.jpg"
  8.  
  9.         If System.IO.File.Exists(FileToCopy) = True Then
  10.             System.IO.File.Copy(FileToCopy, NewCopy)
  11.             MsgBox("File Copied")
  12.         End If
  13.     End Sub

SQL : การนำ Path บันทึกเข้า PHPMyadmin

การบันทึก Path เข้า PHPMyadmin จะนำค่าที่ได้จาก Path บันทึกเข้าโดยตรงไม่ได้
เช่น
ต้องการบันทึก
\\server3\7C งทส\00-อื่น ๆ\Personal Data\สุวิทย์ จำปาหอม\ImageAMS\123.jpg
จะใช้ข้างบนเลยไม่ได้ข้อมูลที่เป็น \ จะไม่เข้า
ถ้าต้องการบันทึกต้อง ใช้ \ และค่าที่ต้องการเช่น \" คือบันทึกค่า " , \\ คือบันทึก \
ถ้าต้องการบันทึก Path ข้างบนก็ต้องใช้
\\\\server3\\7C งทส\\00-อื่น ๆ\\Personal Data\\สุวิทย์ จำปาหอม\\ImageAMS\\123.jpg

วันอังคารที่ 27 กันยายน พ.ศ. 2554

PHP : Code ตัวอย่าง คีย์ข้อมูลใน TextBox แล้วมีค่าล่วงลงมาให้เลือก

Auto Complete a textbox using AJAX, PHP and MySQL

This example illustrates how to create a auto completion text box using AJAX, PHP and MySQL. Data is being retrieved from MySQL database and displayed using AJAX. As of now only mouse movements are being handled but keyboard events are not handled.
The example carries explanation of some parts of the code, while one can download the source,study and reuse as per your convenience. You can download the source from here.
1. index.html
<script language=”JavaScript” type=”text/javascript” src=”suggest.js”></script>
<input type=”text” id=”PoNumber” alt=”Search Criteria” onkeyup=”searchSuggest();” autocomplete=”off”/>
<div id=”layer1″></div>
The page loads the `suggest.js` file wherein the `searchSuggest` function is described. The keyboard event handler in this occasion is the `onkeyup` which checks for each letter that is being entered in the textbox. A div element is also created so that the data that has been passed by JavaScript can be handled.
2. suggest.js
var searchReq = getXmlHttpRequestObject();
This above line creates a httpRequest object for passing values.
function searchSuggest() {
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
var str = escape(document.getElementById(’PoNumber’).value);
searchReq.open(”GET”, ’searchSuggest.php?search=’ + str, true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null);
}
}
`str` gets the value from the textbox. Each word entered in the text box is being passed to this variable which forms a part of the function. Later the values are passed on to the `searchSuggest.php` file which does all the processing.
var curLeft=0;
if (str1.offsetParent){
while (str1.offsetParent){
curLeft += str1.offsetLeft;
str1 = str1.offsetParent;
}
}
`curLeft` defines the current left position which is being initialize to 0 as the begining. `offsetparent` returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. `offsetParent` returns null when the element has style.display set to “none”. Since the element can be inside many hierarchies we loop along with each of them to get hold of the value.
ss.setAttribute(’style’,'position:absolute;top:’+curTop+’;left:’+curLeft+’;width:150;z-index:1;padding:5px;border: 1px solid #000000; overflow:auto; height:105; background-color:#F5F5FF;’);
Here `ss` represents document id of the layer. In the above line the `style` property of the div tag is being set. The `position` should always be `absolute` else the layer will not be formed. The lower elements will be pushed down to accommodate the values that are being retrieved from the database. The `top`, `left` etc. are also being put to show to drop down (div layer). `overflow` is also set so for the scrolling effect in the div tag when it crosses the defined `height`.
The other stuff in the file should be self explanatory as it declares the variables and the functions.
3. database.php
function db_connect($server = ‘localhost’, $username = ‘root’, $password = ‘enigma’, $database = ’suggest’, $link = ‘db_link’)
Please change the `server`, `username`, `password` and `database` name corresponding to yours.
4. searchSuggest.php
A self-explanatory file. This retrieves the data from the database and passes the output to the searchSuggest function in suggest.js.

SQL : Select Concat เอาฟิวล์มาต่อกัน

SQL CONCAT 
เป็นคำสั่งที่ใช้สำหรับการระบุเงื่อนไขการเลือกข้อมูลในตาราง (Table) โดยทำการรวมข้อความเข้าด้วยกัน


Syntax


SELECT CONCAT(Culumn1,Culumn2,...) AS [New-Field] FROM [Table-Name]


Table : customer
CustomerID
Name
Email
CountryCode
Budget
Used
C001
Win Weerachai win.weerachai@thaicreate.com
TH
1000000 600000
C002
John Smith john.smith@thaicreate.com
EN
2000000 800000
C003
Jame Born jame.born@thaicreate.com
US
3000000 600000
C004
Chalee Angel chalee.angel@thaicreate.com
US
4000000 100000


Sample1 การเลือกข้อมูลโดยทำการรวมฟิวด์ CustomerID,Name,Email

SELECT CustomerID,CONCAT(CustomerID,Name,Email) AS ConcatField FROM customer

Output

CustomerID
ConcatField
C001
C001Win Weerachaiwin.weerachai@thaicreate.com
C002
C002John Smithjohn.smith@thaicreate.com
C003
C003Jame Bornjame.smith@thaicreate.com
C004
C004Chalee Angelchalee.angel@thaicreate.com

วันอาทิตย์ที่ 18 กันยายน พ.ศ. 2554

VB.Net : Copy data listview to clipboard in VB.NET

Copy all data in listview.

Code Example :
Imports System.Text

.......

Public Sub CopyListViewToClipboard(ByVal lv As ListView)
        Dim buffer As New StringBuilder

        For i As Integer = 0 To lv.Columns.Count - 1
            buffer.Append(lv.Columns(i).Text)
            buffer.Append(vbTab)
        Next

        buffer.Append(vbCrLf)

        For i As Integer = 0 To lv.Items.Count - 1
            For j As Integer = 0 To lv.Columns.Count - 1
                buffer.Append(lv.Items(i).SubItems(j).Text)
                buffer.Append(vbTab)
            Next
            buffer.Append(vbCrLf)
        Next

        My.Computer.Clipboard.SetText(buffer.ToString)

    End Sub

**** You use call function
Example : call CopyListViewToClipboard(name ListView)