วันพุธที่ 8 มีนาคม พ.ศ. 2560

CSS [ Transparent Drop Down Navigation Menu with CSS and HTML ]


Credit: clevertechie
ประกอบไปด้วย 2 ส่วนคือ HTML และ CSS
รูปภาพจาก https://clevertechie.com/files/nature.jpg

1. HTML Source code

<html>
<link href="style.css" rel="stylesheet">
<ul>
<li><a>Home</a></li>
<li><a>About</a>
<ul>
<li><a>Our Team</a></li>
<li><a>Campian Sites</a></li>
<li><a>Mission &amp; Vision</a></li>
<li><a>Resource</a></li>
</ul>
</li>
<li><a>Think to do</a>
<ul>
<li><a>Activities</a></li>
<li><a>Parks</a></li>
<li><a>Shops</a></li>
<li><a>Events</a></li>
</ul>
</li>
<li><a>Contract</a>
<ul>
<li><a>Map</a></li>
<li><a>Directions</a></li>
</ul>
</li>
<li><a>News</a></li>
</ul>
</html>

2 . CSS Source code

body{
background:url('nature.jpg') no-repeat;
background-size:cover;
font-family:Arial;
color:white;
}
ul{
margin:0px;
padding:0px;
list-style:none;
}
ul li{
float:left;
width:250px;
height:40px;
background-color:black;
opacity:.8;
line-height:40px;
text-align:center;
font-size:20px;
margin-right:2px;
}
ul li a{
text-decoration:none;
color:white;
display:block;
}
ul li a:hover{
background-color:green;
}
ul li ul li{
display:none;
}
ul li:hover ul li{
display:block;
}

C# Language [ ตัวอย่างระบบโอนเงิน (จากต้นทางไปปลายทาง) ]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace BankAccount
{
{
{
InitializeComponent();
}
{
{
cmd.Connection = c;
cmd.CommandText = "select top 1 balance from userAccount where accountName = @userAccountId";
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("userAccountId","admin");
cmd.Connection.Open();

cmd.Connection.Open();


double balance = Convert.ToDouble(cmd.ExecuteScalar());

if (balance < Convert.ToDouble(txtm.Text.Trim()))
{

{
MessageBox.Show("เงินของท่านไม่เพียงพอในการโอน");
cmd.Connection.Close();

cmd.Connection.Close();return;
}

}
cmd.CommandText =@"
update userAccount set balance = @balanceDestination where accountName = @userAccountId_Destination;
update userAccount set balance = @balanceTarget where accountName = @userAccountId_Target
"

update userAccount set balance = @balanceDestination where accountName = @userAccountId_Destination;
update userAccount set balance = @balanceTarget where accountName = @userAccountId_Target
";//เป็นการแอดชื่อ พรามิเตอร์ที่เราใช้มา(ตัวที่เราใช้,ค่าที่เราเอา มาจากไหน)cmd.Parameters.AddWithValue("userAccountId_Destination""admin");
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("balanceDestination", balance - Convert.ToDouble(txtm.Text.Trim()));
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("balanceTarget", balance + Convert.ToDouble(txtm.Text.Trim()));
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("userAccountId_Target",txtget.Text.Trim());
{
}
}
}
}
}
}
}


public partial class FormTransfer : Form{public FormTransfer()

private void btnOK_Click(object sender, EventArgs e)
using (SqlConnection c = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\Documents and Settings\students\My Documents\Visual Studio 2005\Projects\BankAccountSS\BankAccountSS\BankDB.mdf"";Integrated Security=True;User Instance=True"))
SqlCommand cmd = new SqlCommand();

else

{
if (cmd.ExecuteNonQuery() > 0)
MessageBox.Show("เงินได้ถูกโอนไปยังบัญชีปลายทางเรียบร้อยแล้ว");
else{
MessageBox.Show("ระบบขัดข้อง");
}
}

Java language [ Try Catch Finally ]

ภาษาจาวามีคีย์เวิร์ด finally ที่จะมีชุดคำสั่งอยู่ในบล็อกเพื่อระบุให้โปรแกรมทำชุดคำสั่งดังกล่าวหลังจากสิ้นสุดการทำงานของชุดคำสั่งในบล็อก tryหรือ catch

ภาษาจาวาจะทำชุดคำสั่งในบล็อก finally เสมอ แม้ว่าจะมีคำสั่งreturn ในบล็อก try หรือ catch ก่อนก็ตาม กรณีเดียวที่จะไม่ทำชุดคำสั่งในบล็อก finally คือมีคำสั่ง System.exit();

  ตัวอย่างการใช้ try and catch
public class ExceptionHandlingDemoV2 {
public static void main(String args[]) {
try {
int i = Integer.parseInt(args[0]);
System.out.println(4 / i);
} catch(ArithmeticException ex) {
System.out.println(ex.toString());
} catch(NumberFormatException ex) {
System.out.println("Invalid numeric format");
}
}
}
4เราสามารถจะจัดการกับออปเจ็คของ Exception โดยใช้คลาสที่เป็น superclass ของ  Exception นั้นได้ อาทิเช่น เราสามารจัดการกับFileNotFoundException โดยใช้ IOExceptionหรือ Exception แทนได้
4การจัดการกับ Exception มีสองแบบ คือ
ใช้คำสั่ง try/catch
ใช้คำสั่ง throws ในการประกาศเมธอดที่จะมีการเรียกใช้เมธอดใดๆที่อาจส่งออปเจ็คประเภท Exception

4รูปแบบการใช้คำสั่ง throws มีดังนี้
[modifier] return_type methodName([arguments]) throws
ExceptionType[,ExceptionType2] {
...
}
4ตัวอย่าง
public void openfile(String s) throwsFileNotFoundException {
...
   }

4เมธอดใดๆสามารถที่จะจัดการกับ Exception โดยใช้คำสั่งthrows ได้มากกว่าหนึ่งประเภท
4ตัวอย่าง
public void openFile(String s)throwsFileNotFoundException,UnknownHostException{
 ...
      }
4กรณีที่มีการใช้คำสั่ง throws ส่งต่อไปเรื่อยๆ แล้วเมธอด main()ซึ่งเรียกใช้เมธอดสุดท้ายที่ใช้คำสั่ง throws ไม่มีการจัดการกับออปเจ็คประเภท Exception ดังกล่าว  โปรแกรมจะเกิดข้อผิดพลาดในขั้นตอนการรันโปรแกรม เมื่อมีข้อผิดพลาดของออปเจ็คประเภท Exception ดังกล่าวเกิดขึ้น

4เมธอดแบบ overriden จะไม่อนุญาตให้มีการจัดการออปเจ็คประเภท Exception โดยใช้คำสั่ง throws มากชนิดกว่าที่เมธอดเดิมจัดการอยู่ได้

import java.io.*;
public class Parent {
  public void myMethods() throws FileNotFoundException { }
}
public class OverrideExceptionV2 extends Parent {
public void myMethods() throwsFileNotFoundException,IOException {
new FileInputStream("temp.txt");
}
}

4การสร้างคลาสประเภท Exception ขึ้นมาใหม่ สามารถทำได้โดยนิยามคลาสใดๆให้สืบทอดมาจากคลาสที่ชื่อ Exception
4โดยทั่วไปคลาสที่ชื่อ Exception จะมี constructor สองรูปแบบคือ
public Exception()
public Exception(String s)
4ดังนั้นคลาสที่สืบทอดมาจากคลาสที่ชื่อ Exception ควรจะมี constructor ทั้งสองแบบ โดยรูปแบบหนึ่งจะมี argument ที่มีชนิดข้อมูลเป็นString และมีคำสั่งแรกใน constructor เป็นคำสั่ง super(s);

public class MyOwnException extends Exception {
public MyOwnException (String s) {
super(s);
}
}

4เมธอดที่ต้องการส่งออปเจ็คประเภท Exception  เมื่อเกิดข้อผิดพลาดขึ้นในคำสั่งใด จะต้องเรียกใช้คำสั่งที่ชื่อ  throw  เพื่อจะสร้างออปเจ็คของคลาสประเภท Exception ขึ้นมา
4รูปแบบ
throw new ExceptionType([arguments])
4นอกจากนี้คำสั่งประกาศเมธอดนั้นจะต้องมีคำสั่ง throws เพื่อกำหนดให้คำสั่งในเมธอดอื่นๆที่เรียกใช้เมธอดนี้ต้องเขียนคำสั่งในการจัดการกับข้อผิดพลาดนี้

import java.io.*;
public class FileHandler {
    public static void openFile(String filename) throws      MyOwnException {
 File f = new File(filename);
 if (!f.exists()) {
throw new MyOwnException("File Not Found");
 }
    }
}

public class FileOpener {
 public static void main (String args[]) {
try {
FileHandler.openFile(args[0]);
System.out.println("Open successful");
} catch (MyOwnException ex) {
System.err.println(ex);
}
 }
}

Java language [ ว่าด้วยเรื่องของ mod ]

import java.io.*;
class morst 
{
 public static void main(String[] args) throws IOException
 {
  BufferedReader bfr= new BufferedReader(new InputStreamReader(System.in));
  String input,toUpper,mod="";
  int index,check;
  char chk;
  input=bfr.readLine();
  toUpper=input.toUpperCase();
  for(index=0;index<toUpper.length();index++)
   {
    //chk character
    chk=toUpper.charAt(index);
    //check integer
    check=(int)chk;
    if(check==65){mod=mod+".-";}
    if(check==66){mod=mod+"-...";}
    System.out.print(check+" "+chk);
   }
   System.out.print("Output : "+mod);
 }
}

Assembly code [ การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง แบบกลับด้าน ]

Ex. 9 การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง แบบกลับด้าน
data_s segment
str1 db 'daikyo'
str2 db 5 dup(?)
data_s ends
code_s segment
           
main    proc
            assume ds:data_s;cs:code_s
            mov ax,data_s
            mov ds,ax
            mov es,ax
            lea si,str1+6
            lea di,str2
            std
            mov cx,6
move:  
            movsb
            add di,2
            loop move
            mov str2[di],'$'
            lea dx,str2
            mov ah,09h
            int 21h
            mov ah,4ch      
            int 21h
main     endp
code_s ends
end main
x
x

Assembly code [การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง]

Ex. 8 การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง  

data_s segment
str1 db 'daikyo$'
str2 db 7 dup(?)
data_s ends
code_s segment
           
main    proc
            assume ds:data_s;cs:code_s
            mov ax,data_s
            mov ds,ax
            mov es,ax
            lea si,str1
            lea di,str2
            mov cx,7
move:  
            movsb
            loop move
            lea dx,str2
            mov ah,09h
            int 21h
            mov ah,4ch      
            int 21h
main     endp
code_s ends
end main
x

Assembly code [ แสดงข้อความที่พิมพ์เข้าไป ]

Ex. 7 แสดงข้อความที่พิมพ์เข้าไป
dseg     segment
;string buffer
maxlen  db        30                    ;29 chars + 1 return
msglen  db        ?
msg                  db        30 dup (?)        ;29 chars + 1 return
;newline string
newline db        10,13,'$'          
dseg     ends

sseg      segment            stack
            db        100h dup (?)
sseg      ends

cseg     segment
            assume             cs:cseg,ds:dseg,ss:sseg
start:
            mov      ax,dseg             ;set DS
            mov      ds,ax
           
            mov      ah,0Ah             ;read string
            mov      dx,offset maxlen
            int         21h
           
            mov      ah,09h                          ;newline
            mov      dx,offset newline
            int         21h
           
            mov      bl,msglen          ;get string length
            mov      bh,0
           
            mov      msg[bx],'$'       ;terminate string

            mov      ah,09h              ;display it
            mov      dx,offset msg
            int         21h
            mov      ax,4C00h         ;bye-bye
            int         21h
cseg     ends    
end       start

Set Enable .Net framework 3.5 on windows 10 (ติดตั้ง .Netframework 3.5 บนวินโดวน์ 10)

1. Download windows 8.1 file [ TH : ดาวน์โหลดไฟล์ ของ windows 8.1 ] 2. Mount File windows Copy file \sources\sxs from mount drive ...