Wednesday, December 10, 2014

good url

http://teamtreehouse.com/library/topic:learn-android

http://medialoot.com/blog/how-to-create-a-responsive-navigation-menu-using-only-css/

Thursday, November 27, 2014

alert and redirect

window.location='http://localhost:81/friendlyvilla/?page=booking-tour-packages&id=98';
    alert('coming soon...1');

Sunday, November 23, 2014

hide some part of image when it over flow

span { position: relative; display: block; width: 50px; /* Change this */ height: 50px; /* Change this */ overflow: hidden; border: 1px solid #000; } span img { position: absolute; left: -10px; /* Change this */ top: -10px; /* Change this */ }

Wednesday, November 19, 2014

css css

apply css on input tag

.tour-bookingform input[type="text"],input[type="email"], select, input[type="date"], textarea,input[type="number"]{ width: 350px; height:30px; display: block; margin-bottom: 10px; background:#000; color:white }

.menu li li.active a{color:#fff !important}

--------------------------------------------------
Expand clickable area og tag A

.navp a{background:#CCC; border-radius:3px; padding: 7px 7px; margin-left:1px; margin-top:10px; display:inline-block;color:#fd792a}

--------------------------------------------------
Selected Active link

.menu>li.active,.menu>li:hover,.menu li>ul>li.active{
    box-shadow: 0 5px #fd792a;
-moz-box-shadow: 0 5px #fd792a;
-webkit-box-shadow: 0 5px #fd792a;
background: #000;
}

Tuesday, November 18, 2014

Monday, November 17, 2014

keep original width , height when upload

if($info['mime'] == 'image/gif') $src = imagecreatefromgif($uploadedfile); $o_wd = imagesx($src); // original width $o_ht = imagesy($src);// original height }

Saturday, November 8, 2014

Tuesday, November 4, 2014

add class to any tag in one group









Heading 1


Heading 2



This is a paragraph.
This is another paragraph.

This is some important text!





Monday, November 3, 2014

jqmphp

http://demo.jqmphp.com/form-ajax-disabled.php

jquery

http://api.jquery.com/category/traversing/filtering/

monetize from app mobile

1. https://developer.android.com/training/monetization/index.html

2. http://platform.beachfront.io/join

3. http://code4app.net/

Saturday, October 18, 2014

Saturday, October 11, 2014

code upload image with validation (perfect)

if(isset($_POST["btn_new_restaurant"])){
                $galleryname= $_POST['txt_gallery_text'];
$arrayfile=$_FILES["uploadedfile"]["name"] ;
                $tmp_file = $_FILES["uploadedfile"]['tmp_name'];
                $gl_status=$_POST['gl_status'];
$content=$_POST['content'];
                define ("MAX_SIZE","1024");
                function getExtension($str) {
                     $i = strrpos($str,".");
                     if (!$i) { return ""; }
                     $l = strlen($str) - $i;
                     $ext = substr($str,$i+1,$l);
                     return $ext;
                 }
                if(count($arrayfile)>0){
                    for($i=0; $i                        $image =$arrayfile[$i];
                        $uploadedfile = $tmp_file[$i];
                     if($galleryname[$i]!=""){
                        if ($image){
                            $filename = stripslashes($arrayfile[$i]);
                            $extension = getExtension($filename);
                            $extension = strtolower($extension);
                            if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
                                echo '

Unknown Image extension
';
                            }
else{

                                $size=filesize($tmp_file[$i]);
                                if ($size > MAX_SIZE*1024){
                                    echo '
You have exceeded the size limit! Image maximum size 1 Mb
';
                                }else{

if(!empty($tmp_file[$i])){
$info = getimagesize($tmp_file[$i]);

                                    if($extension=="jpg" || $extension=="jpeg" ){
                                        $uploadedfile = $tmp_file[$i];
if ($info['mime'] == 'image/jpeg')
                                        $src = imagecreatefromjpeg($uploadedfile);
                                    }else if($extension=="png"){
                                        $uploadedfile = $tmp_file[$i];
if($info['mime'] == 'image/png')
                                        $src = imagecreatefrompng($uploadedfile);
                                    }else{
if($info['mime'] == 'image/gif')
                                        $src = imagecreatefromgif($uploadedfile);
                                    }
                                    list($width,$height)=getimagesize($uploadedfile);
                                    $newwidth=784;
                                    $newheight=($height/$width)*$newwidth;
                                    $tmp=imagecreatetruecolor($newwidth,$newheight);
if(!empty($src)){
                                    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
                                    $time=mktime(date("h"),date("i"),date("s"),date("d"));
                                    $filename = "../uploads/restaurant/".$time.$arrayfile[$i];
                                    imagejpeg($tmp,$filename,100);
                                    imagedestroy($src);
                                    imagedestroy($tmp);
                                    $data=array(
                                        'restaurant_name'=>$galleryname[$i],
                                        'restaurant_path'=>'uploads/restaurant/'.$time.$arrayfile[$i],
                                        'restaurant_status'=>$gl_status[$i],
'restaurant_desc'=>$content
                                    );
               $new_slide=new Model();
                                        $new_slide->Insert("tbadmin_restaurant", $data);
Image Uploaded Successfully!//Message
}
else{
Not real image file!//Message
}
}
else{
Your file is too big//Message
}
}
                                }
                            }else{
                                You do not choose file to upload//Message
                            }
                         }else{
                             You do not have enter restaurant name..!//Message
                        }
                    }
                }                  
}

Thursday, September 25, 2014

vb.net (Format od Date)

dob.ToString("d/MMM/yyyy", CultureInfo.CreateSpecificCulture("en-US"))

Saturday, September 20, 2014

Friday, September 19, 2014

vb.net ( replace data in datagridview )

 If DataGridView1.Rows(_xdtRow).Cells(0).Value.ToString.Contains("Team") = True Then

           DataGridView1.Rows(_xdtRow).Cells(0).Value="Team that have replaced!"

vb.net (add data to datagridview with condition)

       Dim _xdtRow As Integer = 0
        For _xdtRow = 0 To odt2.Rows.Count - 1
            If Dgvuserlist.Rows.Count < 0 Then
                Dgvuserlist.Rows.Clear()
            Else
                If odt2.Rows(_xdtRow).Item(5).ToString = "0" Then
                    Dgvuserlist.Rows.Add("Male")
                Else
                    Dgvuserlist.Rows.Add("Female")
                End If
            End If
        Next

vb.net (Add data to datatable)

Dim workRow As DataRow = odt2.NewRow()
        workRow("Company ID") = 2
        odt2.Rows.Add(workRow)

Monday, September 15, 2014

vb.net (insert into table with store procedure)

Public Class Form1
    Public conn As OdbcConnection
    Public comm As OdbcCommand
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        conn = New OdbcConnection("dsn=test;uid=root")
        conn.Open()
        'Add the call to the stored procedure including the connection
        Dim cmd As New Odbc.OdbcCommand("{ CALL sp_insertuser2(?,?) }", conn)
        cmd.CommandType = CommandType.StoredProcedure
        'add the parameter to the stored procedure
        Me.TextBox1.Text = CInt(10)
        Me.TextBox2.Text = 2
        Dim IDP As OdbcParameter = cmd.Parameters.Add("@ID", OdbcType.Int)
        Dim NameP As OdbcParameter = cmd.Parameters.Add("@Name", OdbcType.Text)
        IDP.Value = 3
        NameP.Value = "ratana 3"
        cmd.ExecuteNonQuery()
        Conn.Close()
        Conn.Dispose()
    End Sub
End Class

Friday, September 12, 2014

vb.net (find self path)

Dim aPath As String
        Dim aName As String
        aName = System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0).FullyQualifiedName
        aPath = System.IO.Path.GetDirectoryName(aName)
        Dim bm_source As New Bitmap(Bitmap.FromFile(aPath & "\advancedsettings.png"), 40, 40)

Friday, August 29, 2014

vb.net (Assign linq to array)

Imports System
Imports System.Linq
Imports System.Linq.Expressions
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Odbc
Imports System.Data.Common
Public Class UserList
Dim odt As New DataTable
Dim ods As New DataSet
Dim arr As Array
Public Sub UserList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
Form1.connect()
Form1.conn.Open()
Dim comm3 As OdbcCommand
comm3 = New OdbcCommand("SELECT * FROM `tbl_user`", Form1.conn)
Dim myDA As OdbcDataAdapter = New OdbcDataAdapter(comm3)
odt.Columns.Add("User ID", GetType(Int32))
odt.Columns.Add("First Name", GetType(String))
odt.Columns.Add("Last Name", GetType(String))
myDA.Fill(ods, "tbl_user")
myDA.Dispose()
'odt = ods.Tables(0)
Dim users As DataTable = ods.Tables("tbl_user")
ods.Dispose()
'Dim query = From user In users.AsEnumerable()
Dim query = From user In users
Select user
For Each u In query
' MsgBox(u.Field(Of String)("first_name"))
odt.Rows.Add(u.Field(Of Integer)("user_id"), u.Field(Of String)("first_name"), u.Field(Of String)("last_name"))
Next
'''''''''''''
arr = query.ToArray
'odt = ods.Tables(0)
dgView.DataSource = odt
dgView.AllowUserToAddRows = False
dgView.SelectionMode = DataGridViewSelectionMode.FullRowSelect
dgView.Columns(0).HeaderText = "User ID"
dgView.Columns(1).HeaderText = "First Name"
Dim columnHeaderStyle As New DataGridViewCellStyle()
columnHeaderStyle.BackColor = Color.Beige
columnHeaderStyle.Font = New Font("Tahoma", 10, FontStyle.Bold)
dgView.ColumnHeadersDefaultCellStyle = columnHeaderStyle
Me.dgView.DefaultCellStyle.Font = New Font("Tahoma", 10)
dgView.ReadOnly = True
Form1.conn.Close()
End Sub
Private Sub ButtonClose_Click(sender As Object, e As EventArgs) Handles ButtonClose.Click
Me.Close()
End Sub
Private Sub TextBoxsearch_TextChanged(sender As Object, e As EventArgs) Handles TextBoxsearch.TextChanged
Form1.connect()
Form1.conn.Open()
Dim comm3 As OdbcCommand
comm3 = New OdbcCommand("SELECT * FROM `tbl_user` where username like ?", Form1.conn)
comm3.Parameters.AddWithValue("username", "%" & TextBoxsearch.Text & "%")
Dim myDA As OdbcDataAdapter = New OdbcDataAdapter(comm3)
odt.Clear()
myDA.Fill(ods, "tbl_user")
myDA.Dispose()
odt = ods.Tables("tbl_user")
dgView.DataSource = odt
End Sub
Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.Click
FormUser.Show()
Dim dt As New DataTable
dt.Columns.Add("User ID", GetType(Int32))
dt.Columns.Add("First Name", GetType(String))
dt.Columns.Add("Last Name", GetType(String))
For Each u In arr
dt.Rows.Add(CInt(u(0)), u(1).ToString, u(2).ToString)
Next
DataGridView1.DataSource = dt
End Sub
End Class

Tuesday, August 26, 2014

vb.net Culture of Invariant

Imports System.Globalization
Imports System.IO

Public Class Form2

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' Persist the date and time data.
        Dim sw As New StreamWriter(".\DateData.dat")

        ' Create a DateTime value.      
        Dim dtIn As DateTime = DateTime.Now
        ' Retrieve a CultureInfo object.
        Dim invC As CultureInfo = CultureInfo.InvariantCulture

        ' Convert the date to a string and write it to a file.
        sw.WriteLine(dtIn.ToString("r", invC))
        sw.Close()

        ' Restore the date and time data.
        Dim sr As New StreamReader(".\DateData.dat")
        Dim input As String = String.Empty
        Do While sr.Peek() >= 0
            input = sr.ReadLine()
            Console.WriteLine("Stored data: {0}", input)
            Console.WriteLine()

            ' Parse the stored string.
            Dim dtOut As DateTime = DateTime.Parse(input, invC, DateTimeStyles.RoundtripKind)

            ' Create a French (France) CultureInfo object.
            Dim frFr As New CultureInfo("fr-FR")
            ' Displays the date formatted for the "fr-FR" culture.
            Console.WriteLine("Date formatted for the {0} culture: {1}",
                              frFr.Name, dtOut.ToString("f", frFr))

            ' Creates a German (Germany) CultureInfo object.
            Dim deDe As New CultureInfo("de-De")
            ' Displays the date formatted for the "de-DE" culture.
            Console.WriteLine("Date formatted for {0} culture: {1}",
                              deDe.Name, dtOut.ToString("f", deDe))
        Loop
        sr.Close()

        ' The example displays the following output:
        '    Stored data: Tue, 15 May 2012 16:34:16 GMT
        '    
        '    Date formatted for the fr-FR culture: mardi 15 mai 2012 16:34
        '    Date formatted for de-DE culture: Dienstag, 15. Mai 2012 16:34
    End Sub
End Class

Database and Linq



-sql native
 SELECT *, count(*) FROM `tbl_order_detail` a inner join tbl_order b on a.or_id=b.or_id  group by a.or_id

- Linq With Aggregate
Imports System
Imports System.Linq
Imports System.Linq.Expressions
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Odbc
Imports System.Data.Common
Imports System.Globalization

Public Class Form1
    Dim conn As OdbcConnection
    Dim comm As OdbcCommand
    Private Sub connect1()
        conn = New OdbcConnection("dsn=posdb_cafe;uid=root")
        conn.Open()
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim ds As New DataSet()
        ds.Locale = CultureInfo.InvariantCulture
        ' See the FillDataSet method in the Loading Data Into a DataSet topic.
        connect1()
        Dim sqlStr As String = "select * from tbl_item"
        comm = New OdbcCommand(sqlStr, conn)
        Dim myDA As OdbcDataAdapter = New OdbcDataAdapter(comm)
        'conn.Close()
        myDA.Fill(ds, "tbl_item")
        Dim products As DataTable = ds.Tables("tbl_item")
        Dim query = From product In products.AsEnumerable() Where (product.Field(Of String)("item_name")) = "Beef" _
         Or (product.Field(Of String)("item_name")) = "99"
         Select product
        Console.WriteLine("Product Names:")
        For Each p In query
            MsgBox(p.Field(Of String)("item_name"))
        Next
        ''''''''''''''
        Dim sqlStr2 As String = "select * from tbl_order"
        comm = New OdbcCommand(sqlStr2, conn)
        Dim myDA2 As OdbcDataAdapter = New OdbcDataAdapter(comm)
        myDA2.Fill(ds, "tbl_order")
        Dim sqlStr3 As String = "select * from tbl_order_detail"
        comm = New OdbcCommand(sqlStr3, conn)
        Dim myDA3 As OdbcDataAdapter = New OdbcDataAdapter(comm)
        conn.Close()
        myDA3.Fill(ds, "tbl_order_detail")
        Dim orders = ds.Tables("tbl_order").AsEnumerable()
        Dim details = ds.Tables("tbl_order_detail").AsEnumerable()
        Dim query2 = _
                From order In orders _
                Group Join detail In details On order.Field(Of Integer)("or_id") _
                    Equals detail.Field(Of Integer)("or_id") Into ords = Group _
                Select New With _
                    { _
                        .CustomerID = order.Field(Of Integer)("or_id"), _
                        .ords = ords.Count(), _
                        .AverageListPrice = ords.Average(Function(detail) _
                        detail.Field(Of Integer)("or_id"))
                    }
        For Each order In query2
            Console.WriteLine("CustomerID: {0}  Orders Count: {1} Orders avg: {2}", _
        order.CustomerID, order.ords, order.AverageListPrice)
        Next
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Form2.Show()
    End Sub

End Class

Saturday, August 23, 2014

DataReader

            conn = New OdbcConnection("dsn=poscafe;uid=root;")
            sqlStr = "select * from table_answer"
            conn.Open()
            comm = New OdbcCommand(sqlStr, conn)
            dr = comm.ExecuteReader
            comm.Dispose()
            If dr.Read Then
                MsgBox(dr("answer_id"))
            End If

vb.net (md5hash)

 Function getMD5Hash(ByVal strToHash As String) As String
        Dim md5Obj As New System.Security.Cryptography.MD5CryptoServiceProvider
        Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
        bytesToHash = md5Obj.ComputeHash(bytesToHash)
        Dim strResult As String = ""
        For Each b As Byte In bytesToHash
            strResult += b.ToString("x2")
        Next
        Return strResult
    End Function

vb.net (related database)

Imports System.Data.Odbc
Imports System.Data.DataRow
Imports System.Windows.Forms
Public Class Form1
    Public conn As OdbcConnection
    Public comm As OdbcCommand
    Public sqlStr As String
    Dim ods As New DataSet
    Dim odt As New DataTable
    Dim dr As OdbcDataReader
    Dim num As Integer = 0
    Dim cell As DataGridViewCell
    Public ans_id As Integer
    Private Sub connect1()
        conn = New OdbcConnection("dsn=poscafe;uid=root;")
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.WindowState = FormWindowState.Maximized
        Me.dgView.DefaultCellStyle.Font = New Font("Tahoma", 15)

        dgView.ColumnHeadersVisible = True

        ' Set the column header style.
        Dim columnHeaderStyle As New DataGridViewCellStyle()

        columnHeaderStyle.BackColor = Color.Beige
        columnHeaderStyle.Font = New Font("Tahoma", 15, FontStyle.Bold)
        dgView.ColumnHeadersDefaultCellStyle = columnHeaderStyle

        Try
            connect1()
            'conn = New OdbcConnection("dsn=poscafe;uid=root;")
            sqlStr = "select * from table_answer"
            conn.Open()
            comm = New OdbcCommand(sqlStr, conn)
            'dr = comm.ExecuteReader
            'If dr.Read Then
            '    MsgBox(dr("answer_id"))
            'End If
            Dim myDA As OdbcDataAdapter = New OdbcDataAdapter(comm)
            myDA.Fill(ods, "table_answer")
            odt = ods.Tables("table_answer")
            dgView.SelectionMode = DataGridViewSelectionMode.FullRowSelect
            dgView.AllowUserToAddRows = False
            dgView.DataSource = odt
            Dim column As DataGridViewColumn = dgView.Columns(1)
            column.Width = 200
            dgView.Columns(0).HeaderText = "Code"
            dgView.Columns(1).HeaderText = "Question ID"
            dgView.ReadOnly = True
            conn.Close()
            ans_id = odt.Rows(num).Item(0)
            id.Text = ans_id
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Buttonnext_Click(sender As Object, e As EventArgs) Handles Buttonnext.Click
        dgView.Rows(num).Selected = False
        num += 1
        If num > (odt.Rows.Count - 1) Then
            num -= 1
            dgView.Rows(num).Selected = True
            Exit Sub
        End If
        dgView.Rows(num).Selected = True
        id.Text = odt.Rows(num).Item("answer_id").ToString
        ans_id = odt.Rows(num).Item(0)
        dgView.Columns(0).HeaderText = "Code"
    End Sub

    Private Sub Buttonprevious_Click(sender As Object, e As EventArgs) Handles Buttonprevious.Click
        dgView.Rows(num).Selected = False
        num -= 1
        If num < 0 Then
            num += 1
            dgView.Rows(num).Selected = True
            Exit Sub
        End If
        'TextBox1.Text = odt.Rows(num).Item("answer_id").ToString
        dgView.Rows(num).Selected = True
        id.Text = odt.Rows(num).Item("answer_id").ToString
        ans_id = odt.Rows(num).Item(0)
    End Sub

    Private Sub buttonsave_Click(sender As Object, e As EventArgs) Handles buttonsave.Click
        Try
            'comm.Connection = conn
            'connect1()
            conn.Open()
            Dim insertSQL As String = "INSERT INTO table_answer(question_id,answer,image) VALUES (?,?,?)"
            comm = New OdbcCommand(insertSQL, conn)
            comm.Parameters.AddWithValue("question_id", Textquestionid.Text)
            comm.Parameters.AddWithValue("answer", Textanswer.Text)
            comm.Parameters.AddWithValue("image", Textimage.Text)
            comm.ExecuteNonQuery()
            comm.Dispose()
            comm = Nothing
            conn.Close()
            odt.Clear()
            num += 1
            Call Alldata()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Alldata()
        Call connect1()
        sqlStr = "select * from table_answer"
        conn.Open()
        comm = New OdbcCommand(sqlStr, conn)
        'dr = comm.ExecuteReader
        'If dr.Read Then
        '    MsgBox(dr("answer_id"))
        'End If
        Dim myDA As OdbcDataAdapter = New OdbcDataAdapter(comm)
        myDA.Fill(ods, "table_answer")
        odt = ods.Tables("table_answer")
        dgView.DataSource = odt
        conn.Close()
        dgView.Rows(0).Selected = False
        dgView.Rows(num).Selected = True
        id.Text = odt.Rows(num).Item(0)
    End Sub

    Private Sub dgView_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgView.CellClick
        'MsgBox(dgView.CurrentRow.Index)
        'MsgBox(dgView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
        'If IsNumeric(dgView.Rows(e.RowIndex).Cells(0).Value) Then
        'MsgBox(dgView.Rows(e.RowIndex).Cells(0).Value)
        Me.id.Text = dgView.Rows(e.RowIndex).Cells(0).Value
        dgView.Rows(num).Selected = False
        num = dgView.CurrentRow.Index
        ans_id = odt.Rows(num).Item(0)
        'End If
    End Sub

    Private Sub dgView_KeyUp(sender As Object, e As KeyEventArgs) Handles dgView.KeyUp
        'If (dgView.Rows.Count - 1) = dgView.CurrentRow.Index Then
        'MsgBox("no value in this row")
        'Else
        Select Case e.KeyCode
            Case Keys.Up
                'MsgBox(dgView.SelectedRows(0).Cells(0).Value)
                Me.id.Text = dgView.SelectedRows(0).Cells(0).Value
                ans_id = dgView.SelectedRows(0).Cells(0).Value
                num = dgView.CurrentRow.Index
            Case Keys.Down
                'MsgBox(dgView.SelectedRows(0).Cells(0).Value)
                Me.id.Text = dgView.SelectedRows(0).Cells(0).Value
                ans_id = dgView.SelectedRows(0).Cells(0).Value
                 num = dgView.CurrentRow.Index
        End Select
        'End If
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Form2.Show()
    End Sub

    Private Sub update_Click(sender As Object, e As EventArgs) Handles update.Click
        Try
            conn.Open()
            Dim updateSQL As String = "update table_answer set question_id=?,answer=?,image=? where answer_id=?"
            comm = New OdbcCommand(updateSQL, conn)
            comm.Parameters.AddWithValue("question_id", Textquestionid.Text)
            comm.Parameters.AddWithValue("answer", Textanswer.Text)
            comm.Parameters.AddWithValue("image", Textimage.Text)
            comm.Parameters.AddWithValue("answer_id", id.Text)
            comm.ExecuteNonQuery()
            odt.Clear()
            Call Alldata()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        'comm.Connection = conn
        'connect1()
    End Sub
    Private Sub delete_Click(sender As Object, e As EventArgs) Handles delete.Click
        Dim rowaff As Integer
        Try
            conn.Open()
            Dim deleteSQL As String = "delete from table_answer where answer_id=?"
            comm = New OdbcCommand(deleteSQL, conn)
            comm.Parameters.AddWithValue("answer_id", id.Text)
            rowaff = comm.ExecuteNonQuery()
            If rowaff = 1 And num <> 0 Then
                num -= 1
            End If
            odt.Clear()
            Call Alldata()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

vb.net onpain(source, entire clone from source and path of clone from source)

Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Windows.Forms
Imports System.IO
Public Class Form1
    Overloads Function CopyBitmap(source As Bitmap) As Bitmap
        Return New Bitmap(source)
    End Function
    Overloads Function CopyBitmap(source As Bitmap, part As Rectangle) As Bitmap
        Dim bmp As New Bitmap(part.Width, part.Height)
        Dim g As Graphics = Graphics.FromImage(bmp)
        g.DrawImage(source, 0, 0, part, GraphicsUnit.Pixel)
        g.Dispose()
        Return bmp
    End Function
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
        Dim arialFont As Font
        Dim blackBrush As Brush
        arialFont = New Font("Arial", 10, FontStyle.Regular)
        blackBrush = New SolidBrush(Color.Black)
        Dim sidesize As Integer = 300
        Dim third As Integer = CInt(sidesize / 3)
        Dim bm_sourceaa As New Bitmap(Bitmap.FromFile("C:\Users\Laptop\Desktop\troll\cute girl2.jpg"))
        Dim bm_source As New Bitmap(Bitmap.FromFile("C:\Users\Laptop\Desktop\troll\cute girl2.jpg"), _
            CInt(200), bm_sourceaa.Height * 200 / bm_sourceaa.Width)
        ' Copy entirely as a clone.
        Dim clone As Bitmap = CopyBitmap(bm_source)
        ' Copy the center part of the bitmap.
        Dim center As Bitmap =  CopyBitmap(bm_source, New Rectangle(0, 100, 100, 50))
        Dim DestPath As String = "C:\Users\Laptop\Desktop\rathana\"
        If Not Directory.Exists(DestPath) Then
            Directory.CreateDirectory(DestPath)
        End If
        clone.Save("C:\Users\Laptop\Desktop\rathana\2newbitmap.bmp", ImageFormat.Bmp)
        Dim y As Integer = 10
        e.Graphics.DrawString("source bitmap:", arialFont, blackBrush, 10, y)
        y += 20
        e.Graphics.DrawImage(bm_source, 10, y)
        y += bm_source.Height + 10
        e.Graphics.DrawString("clone bitmap:", arialFont, blackBrush, 10, y)
        y += 20
        e.Graphics.DrawImage(clone, 10, y)
        y += clone.Height + 10
        e.Graphics.DrawString("center part of bitmap:", arialFont, blackBrush, 10, y)
        y += 20
        e.Graphics.DrawImage(center, 10, y)
        y += center.Height + 10
        'Dispose graphic objects.
        arialFont.Dispose()
        blackBrush.Dispose()
    End Sub
End Class

vb.net (Add)

1. Browse to show image on form 

Private Sub Buttonaddimage_Click(sender As Object, e As EventArgs) Handles Buttonaddimage.Click
        Dim ofd As New OpenFileDialog
        If ofd.ShowDialog = DialogResult.OK Then
            If ofd.FileName <> String.Empty Then
                imgpath = ofd.FileName
                Dim bm_source As New Bitmap(Bitmap.FromFile(ofd.FileName), 200, 200)
                PictureBox1.Image = bm_source
            End If
        End If
    End Sub

2. Add Item include image

Private Sub additem_Click(sender As Object, e As EventArgs) Handles additem.Click
        Dim comm2 As New OdbcCommand
        Dim comm3 As New OdbcCommand
        Dim status As Byte
        Dim userid2 As Byte
        Form1.connect()
        Form1.conn.Open()
        comm2 = Form1.comm
        Dim itemgroupid As Integer
        comm2 = New OdbcCommand("INSERT INTO `tbl_item`(`igroup_id`, `item_code`, `item_name`, `qty`, `price_out`, `expire_date`, `image`, `status_id`, `created_date`, `created_by`) VALUES (?,?,?,?,?,?,?,?,?,?)", Form1.conn)
        Dim comm As New OdbcCommand
        Dim odt As New DataTable
        Dim ods As New DataSet
        comm3 = New OdbcCommand("select igroup_id from tbl_item_group where igroup_name='" & ComboBoxitemgroup.Text & "'", Form1.conn)
        Dim myDA As OdbcDataAdapter = New OdbcDataAdapter(comm3)
        myDA.Fill(ods, "tbl_item_group")
        odt = ods.Tables("tbl_item_group")
        itemgroupid = odt.Rows(0).Item(0)
        comm2.Parameters.AddWithValue("igroup_id", itemgroupid)
        comm2.Parameters.AddWithValue("item_code", Me.TextBoxitemcode.Text)
        comm2.Parameters.AddWithValue("item_name", Me.TextBox1.Text)
        comm2.Parameters.AddWithValue("qty", Me.TextBoxquantity.Text)
        comm2.Parameters.AddWithValue("price_out", Me.TextBoxsellout.Text)
        comm2.Parameters.AddWithValue("expire_date", CDate(Me.DateTimePicker1.Text))

        Dim bm_source As New Bitmap(Bitmap.FromFile(imgpath), 400, 400)

        Dim clone As Bitmap = CopyBitmap(bm_source)
        Dim timeStamp As String = DateTime.Now.ToString("yyyyMMddhhmmss")

        clone.Save("C:\Users\Laptop\Desktop\rathana\" & timeStamp & ".bmp", ImageFormat.Bmp)
        comm2.Parameters.AddWithValue("image", "C:\Users\Laptop\Desktop\rathana\" & timeStamp & ".bmp")

        If Comitemstatus.Text = "Active" And Comitemstatus.Text <> "" Then
            status = 1
        Else
            status = 0
        End If
        comm2.Parameters.AddWithValue("status_id", status)
        comm2.Parameters.AddWithValue("created_date", Now)
        userid2 = Form1.userid
        comm2.Parameters.AddWithValue("created_by", userid2)
        comm2.ExecuteNonQuery()
        Form1.conn.Close()
    End Sub

Wednesday, July 23, 2014

Wednesday, July 2, 2014

jQuery not working after the content is loaded through AJAX



$(document) refers to the whole document.
$(document).on('click', "#click", function () {
    $('#click').css({
        "background-color": "#fff",
        "color": "#000",
        "cursor": "inherit"
    }).text("Open this window again and this message will still be here.");
    return false;
});


jquery with page loaded by ajax

 
  $(document).on('click', "#checkall", function () {
    $(".tours_table tr").not(".tours_table tr:eq(0)").click(function(){
       $(this).toggleClass("selecting");
    });
   
    $("#checkall").change(function () {
    $(".tours_table table input:checkbox").prop('checked', $(this).prop("checked"));
    });
   
    $(".tours_table table input:checkbox").not("#checkall").change(function(){
       if($("#checkall:checkbox").attr("checked","checked")){
        $("#checkall:checkbox").removeAttr("checked");}
    });
  
  
  });

ajax with codeigniter

function delete1(){
        var  num_record1 = new Array();
    $('.checkname1:checked').each(function () {
        var e = $(this);
        num_record1.push(e.val());
    });
            var showarray=new Array();
        $.ajax({
            type:'post',
            url:'deletetours',
            data:{showarray:num_record1},
            success: function(data) {
                $("#showtype").html(data);
                }
                ,
            error: function() {
                alert('error');
            }
        });
    //});
}

Tuesday, June 10, 2014

Monday, May 26, 2014

alias configuration

C:\wamp\bin\apache\Apache2.4.4\conf\extra

configure in file(httpd-vhosts.conf):


ServerAdmin webmaster@myadminv2
DocumentRoot "D:\Dropbox\IT KHMER SHARE\myadmin_v2.00"
ServerName myadminv2
 
AllowOverride all
Allow From All


-------------------------------------------------------------------

C:\Windows\System32\Drivers\etc

configure in other file(hosts):

127.0.0.1       localhost
127.0.0.1       myadminv2
127.0.0.1       myadminv3

-------------------------------------------------------------------
C:\wamp\bin\apache\Apache2.4.4\conf

uncomment infront of the sentence below

Include conf/extra/httpd-vhosts.conf

-------------------------------------------------------------------
check before sentence below

rewrite module









Saturday, May 24, 2014

redirect to any page

Window.open("url",true); (can not)
Window.location.href="url",true; (can)
Alert("msg",window.location.href="url",true);

Thursday, May 8, 2014

mailserver

http://www.arclab.com/en/amlc/list-of-smtp-and-imap-servers-mailserver-list.html

Tuesday, April 1, 2014

how to add google translate

http://support.jimdo.com/tutorials/apps-and-plugins/how-to-add-google-translate-to-your-website/

Monday, March 31, 2014

html5

Untitled Document
Head
section
Article
foot

Sunday, March 23, 2014

remove text decoration

CSS CODE #navcontainer ul { margin: 0; padding: 0; list-style-type: none; } #navcontainer ul li { display: inline; } #navcontainer ul li a { text-decoration: none; } HTML CODE

css menu N box-shadow

ul li{ text-decoration:none; padding-left:50px; padding-right:50px} .nav li{ display:block; padding: 5px 5px; background:#09C;margin-bottom:1px; width:170px} li:hover{background:#99F} https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow

Monday, March 17, 2014

embed font

@font-face { font-family:'xyzfont'; src: url('fonts/abc-font.eot?') format('eot'), url('fonts/abc-font.woff') format('woff'), url('fonts/abc-font.ttf') format('truetype'); } .siemreap{ color:#FFF; float:right ; font-size:24px; margin: 10px 10px; font-family: 'xyzfont', Georgia, Arial; }

Tuesday, March 11, 2014

css third level dropdown menu

nav li ul li ul li{ background: #e4ca3b; display: none; height: auto; padding: 0px; margin: 0px; border: 0px; position: absolute; width: auto; z-index: 200; left:3px; } nav li ul li:hover ul li{ height: auto; padding: 0px; margin: 0px; border: 0px; position:relative; width: auto; z-index: 200; left:3px;display:block }

Friday, February 14, 2014

compress image during upload

function compress_image($source_url, $destination_url, $quality) { $info = getimagesize($source_url); if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url); elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url); elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url); imagejpeg($image, $destination_url, $quality); return $destination_url; } if(isset($_FILES['add_image1'])){ $tt=time(); $target_path = "../product_image/".$tt; $target_path = $target_path . basename( $_FILES["add_image1"]['name']); $pn="product_image/".basename( $_FILES["add_image1"]['name']); $ch=strtolower(substr($pn, strrpos($pn,".")+1)); if($ch=="jpg" or $ch=="png" or $ch=="jpeg" or $ch=="gif"){ if(move_uploaded_file($_FILES['add_image1']['tmp_name'], $target_path)) { mysqli_query($db_con,"update table_question set image='".$target_path."' where question_id=".$pro_id); $destination=$target_path; $t=compress_image($target_path,$destination, 50); if($t!=''){ mysqli_query($db_con,"update table_question set image='".$filename."' where question_id=".$pro_id); } } } }

resize image during upload

if(isset($_FILES['add_image1'])){ $tt=time(); $target_path = "../product_image/".$tt; $target_path = $target_path . basename( $_FILES["add_image1"]['name']); $pn="product_image/".basename( $_FILES["add_image1"]['name']); $ch=strtolower(substr($pn, strrpos($pn,".")+1)); if($ch=="jpg" or $ch=="png" or $ch=="jpeg" or $ch=="gif"){ $uploadedfile = $_FILES['add_image1']['tmp_name']; //$size=filesize($_FILES['add_image1']['tmp_name']); if (!empty($uploadedfile)){ $info = getimagesize($uploadedfile); if($ch=="jpg" || $ch=="jpeg" ) { if ($info['mime'] == 'image/jpeg') $src = imagecreatefromjpeg($uploadedfile); } else if($ch=="png") { if($info['mime'] == 'image/png') $src = imagecreatefrompng($uploadedfile); } else { if($info['mime'] == 'image/gif') $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $newwidth=100; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); if(!empty($src)){ imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = "../product_image/".$tt. $_FILES['add_image1']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); mysqli_query($db_con,"update table_question set image='".$filename."' where question_id=".$pro_id); } } } }

ajax opens php file

function showTYPE(str) { var xmlhttp1, str; if (str.length==0) { showtype.innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp1=new XMLHttpRequest(); //alert("hi"); } else {// code for IE6, IE5 xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp1.open("GET","type.php?q="+str,true); xmlhttp1.send(); xmlhttp1.onreadystatechange=function() { //document.write(xmlhttp1.responseText); showtype.innerHTML=xmlhttp1.responseText; } }

Access to Folder in C and D Drive

Drive D 1. D: / 2. cd "D:\foldername" Drive C 1. cd\ 2. cd foldername/foldername