เขียนโปรแกรม Java NetBeans บนฐานข้อมูล MySQL Server 5.5

ในห้อง 'คอมพิวเตอร์ & อินเตอร์เน็ต' ตั้งกระทู้โดย ledphong, 23 มกราคม 2015.

  1. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    ตัวอย่าง FormAdd บางตอน
    ====================
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.java.myapp</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Dimension</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Toolkit</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.KeyEvent</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Connection</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.DriverManager</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.PreparedStatement</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.ResultSet</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Statement</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Scanner</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JOptionPane</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JTable</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.table.DefaultTableModel</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FormAdd <span style="color: #000000; font-weight: bold;">extends</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JInternalFrame</span> <span style="color: #009900;">{</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">Connection</span> connect = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">DefaultTableModel</span> dt = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-weight: bold;">int</span> CodePK = <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Budget,Sex,FullName,IDCard,BanID,Moo,Poverty,Help,<span style="color: #003399; font-weight: bold;">Comment</span>,CodeID = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-weight: bold;">float</span> Money<span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">Statement</span> st = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">ResultSet</span> rs = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399; font-weight: bold;">JTable</span> table<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//new</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> FormAdd<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    initComponents<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    setTitle<span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;เพิ่มรายการ / แก้ไขรายการ&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-weight: bold;">int</span> inset = <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">Dimension</span> screenSize = <span style="color: #003399; font-weight: bold;">Toolkit</span>.<span style="color: #006633;">getDefaultToolkit</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">getScreenSize</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    setBounds<span style="color: #009900;">(</span>inset<span style="color: #339933;">*</span><span style="color: #cc66cc;">6</span>, inset, screenSize.<span style="color: #006633;">width</span> - inset <span style="color: #339933;">*</span> <span style="color: #cc66cc;">12</span>, screenSize.<span style="color: #006633;">height</span>-inset <span style="color: #339933;">*</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//=============Connection MySQL==============</span>
    <span style="color: #000000; font-weight: bold;">try</span>
    <span style="color: #009900;">{</span>
    <span style="color: #666666; font-style: italic;">//connect=DriverManager.getConnection(&quot;jdbc:ucanaccess://C:\\java\\dbHelp.mdb&quot;);</span>
    <span style="color: #003399; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    connect = <span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:mysql://localhost/dbHelp&quot;</span> +
    <span style="color: #0000ff;">&quot;?user=root&amp;password=gomplayer&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//JOptionPane.showMessageDialog(null,&quot;Connect Database Successfully&quot;);</span>
    <span style="color: #666666; font-style: italic;">//showdata();</span>
    ClearAll<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Connect Database Failed!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #666666; font-style: italic;">//===========================================</span>
    <span style="color: #009900;">}</span></pre>
     
  2. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    ปุ่ม GenID หรือกำหนดเลขแบบ Auto
    =========================
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnGenIDActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    GenIDAuto<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">boolean</span> GenIDAuto<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">Boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">String</span> sql = <span style="color: #0000ff;">&quot;SELECT max(CodePK) FROM tblHelp&quot;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//ใช้กับ MySQL</span>
    <span style="color: #666666; font-style: italic;">//String sql = &quot;SELECT nvl(max(CodePK),0) FROM tblHelp&quot;; //ใช้กับ MS Access 2003</span>
    pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span>sql<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    rs = pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    &nbsp;
    <span style="color: #006600; font-weight: bold;">int</span> maxID = rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>+<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    &nbsp;
    txtCodePK.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>maxID<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> paded = <span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">format</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;%7s&quot;</span>,<span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>maxID<span style="color: #009900;">)</span><span style="color: #009900;">)</span>.<span style="color: #006633;">replace</span><span style="color: #009900;">(</span><span style="color: #0000ff;">' '</span>, <span style="color: #0000ff;">'0'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodeID.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;CUS&quot;</span>+paded<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #666666; font-style: italic;">//ปิดปุ่ม</span>
    btnGenID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnEdit.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnDelete.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnSearch.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #666666; font-style: italic;">//ปิด textBox</span>
    txtSearch.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodePK.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodeID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Error Auto GenID!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span></pre>
     
    แก้ไขครั้งล่าสุดโดยผู้ดูแล: 24 มกราคม 2015
  3. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> ClearAll<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    txtCodePK.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbBudget.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbSex.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtFullName.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtIDCard.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtBanID.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbMoo.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtPoverty.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbHelp.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtMoney.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;0.00&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//0.00</span>
    cbComment.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodeID.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtSearch.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jComboBox1.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jComboBox2.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jComboBox3.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Error Clear All Data!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span></pre>
     
  4. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">boolean</span> InsertData<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">String</span> CodePK = txtCodePK.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Budget = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbBudget.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Sex = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbSex.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> FullName = txtFullName.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> IDCard = txtIDCard.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> BanID = txtBanID.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Moo = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbMoo.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Poverty = txtPoverty.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Help = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbHelp.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Money = txtMoney.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> <span style="color: #003399; font-weight: bold;">Comment</span> = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbComment.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> CodeID = txtCodeID.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> MyD = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>jComboBox1.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> MyDateMonth = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>jComboBox2.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> MyDateYear = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>jComboBox3.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>CodePK.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณากดปุ่ม GenID ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodePK.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//(cbBudget.getItemCount() != 0)) ค่า ComboBox ว่าง</span>
    <span style="color: #666666; font-style: italic;">//JcomboBox.setSelectedIndex(-1);</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>cbBudget.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาเลือก ปีงบประมาณ ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbBudget.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>cbSex.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาเลือก เพศ ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbSex.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>FullName.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาพิมพ์ ชื่อ-สกุล ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtFullName.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>cbMoo.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาเลือก หมู่ที่ ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbMoo.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>Poverty.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาพิมพ์ ความยากจน ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtPoverty.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>cbHelp.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาเลือก ความช่วยเหลือ ก่อนครับ &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbHelp.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">Boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    <span style="color: #666666; font-style: italic;">//connect=DriverManager.getConnection(&quot;jdbc:ucanaccess://C:\\java\\dbHelp.mdb&quot;);</span>
    <span style="color: #003399; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    connect = <span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:mysql://localhost/dbHelp&quot;</span> +
    <span style="color: #0000ff;">&quot;?user=root&amp;password=gomplayer&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;INSERT INTO tblHelp&quot;</span>+
    <span style="color: #0000ff;">&quot;(CodePK,Budget,Sex,FullName,IDCard,BanID,Moo,&quot;</span> +
    <span style="color: #0000ff;">&quot;Poverty,Help,Money,Comment,CodeID,MyDateDay,MyDateMonth,MyDateYear)&quot;</span>+
    <span style="color: #0000ff;">&quot;VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>, CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">2</span>, Budget<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">3</span>, Sex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">4</span>, FullName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">5</span>, IDCard<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">6</span>, BanID<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">7</span>, Moo<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">8</span>, Poverty<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">9</span>, Help<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">10</span>, Money<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">11</span>, <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">12</span>, CodeID<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">13</span>, MyD<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">14</span>, MyDateMonth<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">15</span>, MyDateYear<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//pstmt.setString(16,((JTextField).dob.getDateEditor().getUiCoponent()).getText());//เวลา</span>
    pstmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;บันทึกข้อมูลเรียบร้อยแล้ว&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">INFORMATION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    btnRefresh.<span style="color: #006633;">doClick</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> e<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;บันทึกข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span></pre>
     
  5. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">boolean</span> UpdateData<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>txtCodePK.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาพิมพ์ค้นหาข้อมูลก่อนและกดปุ่มค้นหา&quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">PLAIN_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtSearch.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #006600; font-weight: bold;">int</span> CodePK = <span style="color: #003399; font-weight: bold;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">(</span>txtCodePK.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Budget = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbBudget.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Sex = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbSex.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> FullName = txtFullName.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> IDCard = txtIDCard.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> BanID = txtBanID.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Moo = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbMoo.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Poverty = txtPoverty.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> Help = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbHelp.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-weight: bold;">float</span> Money = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Float</span><span style="color: #009900;">(</span>txtMoney.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> <span style="color: #003399; font-weight: bold;">Comment</span> = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>cbComment.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> MyD = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>jComboBox1.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> DateMonth = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>jComboBox2.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> DateYear = <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">)</span>jComboBox3.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">Boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    connect = <span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:mysql://localhost/dbHelp&quot;</span> +
    <span style="color: #0000ff;">&quot;?user=root&amp;password=gomplayer&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;UPDATE tblHelp SET &quot;</span> +
    <span style="color: #0000ff;">&quot;Budget = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Sex = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;FullName = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;IDCard = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;BanID = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Moo = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Poverty = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Help = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Money = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Comment = ?, &quot;</span>+
    <span style="color: #0000ff;">&quot;MyDateDay = ?, &quot;</span>+
    <span style="color: #0000ff;">&quot;MyDateMonth = ?, &quot;</span>+
    <span style="color: #0000ff;">&quot;MyDateYear = ? &quot;</span>+
    <span style="color: #0000ff;">&quot;WHERE CodePK = ?&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>, Budget<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">2</span>, Sex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">3</span>, FullName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">4</span>, IDCard<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">5</span>, BanID<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">6</span>, Moo<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">7</span>, Poverty<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">8</span>, Help<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setFloat</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">9</span>, Money<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">10</span>, <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">11</span>, MyD<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">12</span>, DateMonth<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">13</span>, DateYear<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">14</span>, CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;แก้ไขข้อมูลเรียบร้อยแล้ว&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">INFORMATION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    btnRefresh.<span style="color: #006633;">doClick</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> e<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;แก้ไขข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span></pre>
     
  6. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">boolean</span> DeleteData<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>txtCodePK.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาพิมพ์ค้นหาข้อมูลก่อนและกดปุ่มค้นหา&quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">PLAIN_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtSearch.<span style="color: #006633;">requestFocusInWindow</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">Boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-weight: bold;">int</span> conf = <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showConfirmDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;คุณต้องการลบข้อมูลหรือไม่&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">YES_NO_OPTION</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>conf==<span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #006600; font-weight: bold;">int</span> CodePK = <span style="color: #003399; font-weight: bold;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">(</span>txtCodePK.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    <span style="color: #666666; font-style: italic;">//connect=DriverManager.getConnection(&quot;jdbc:ucanaccess://C:\\java\\dbHelp.mdb&quot;);</span>
    <span style="color: #003399; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    connect = <span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:mysql://localhost/dbHelp&quot;</span> +
    <span style="color: #0000ff;">&quot;?user=root&amp;password=gomplayer&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;DELETE FROM tblHelp WHERE CodePK = ?&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>, CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;ลบข้อมูลเรียบร้อยแล้ว&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">INFORMATION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    btnRefresh.<span style="color: #006633;">doClick</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;ลบข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span></pre>
     
  7. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    <pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnSearchActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span><span style="color: #009900;">(</span>txtSearch.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #339933;">&amp;&amp;</span> txtCodePK.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,
    <span style="color: #0000ff;">&quot;กรุณาพิมพ์ค้นหาข้อมูลก่อน &quot;</span> ,
    <span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">PLAIN_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">Scanner</span> scanner = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Scanner</span><span style="color: #009900;">(</span>txtSearch.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span>scanner.<span style="color: #006633;">hasNextInt</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    connect = <span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:mysql://localhost/dbHelp&quot;</span> +
    <span style="color: #0000ff;">&quot;?user=root&amp;password=gomplayer&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">String</span> sql = <span style="color: #0000ff;">&quot;Select * from tblHelp &quot;</span> +
    <span style="color: #0000ff;">&quot;Where CodePK LIKE '&quot;</span> + txtSearch.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> + <span style="color: #0000ff;">&quot;' &quot;</span> <span style="color: #339933;">;</span>
    pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span>sql<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    rs = pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span><span style="color: #339933;">!</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;ไม่พบข้อมูลที่ต้องการค้นหา&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">INFORMATION_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtSearch.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">do</span><span style="color: #009900;">{</span>
    txtCodePK.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;CodePK&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbSex.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Sex&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtFullName.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;FullName&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtIDCard.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;IDCard&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtBanID.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;BanID&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbMoo.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Moo&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtPoverty.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Poverty&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbHelp.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Help&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtMoney.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Money&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//txtMoney.setText(df.format(Double.parseDouble(rs.getString(&quot;Money&quot;))));</span>
    txtCodeID.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;CodeID&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbBudget.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Budget&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbComment.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Comment&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jComboBox1.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;MyDateDay&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jComboBox2.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;MyDateMonth&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jComboBox3.<span style="color: #006633;">setSelectedItem</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;MyDateYear&quot;</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #666666; font-style: italic;">//ปิดปุ่มและtextBox</span>
    btnGenID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnAdd.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnSearch.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtSearch.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodePK.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodeID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">(</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;ไม่สามารถแสดงข้อมูลได้!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;ข้อมูลที่ป้อนเข้ามาไม่ใช่ตัวเลขครับ&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtSearch.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> txtSearchKeyPressed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">KeyEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>evt.<span style="color: #006633;">getKeyCode</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>==<span style="color: #003399; font-weight: bold;">KeyEvent</span>.<span style="color: #006633;">VK_ENTER</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    btnSearch.<span style="color: #006633;">doClick</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #666666; font-style: italic;">//ปิดปุ่มและ textBox</span>
    txtCodePK.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodeID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnGenID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnAdd.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Error Refresh Data!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnAddActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    InsertData<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnEditActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    UpdateData<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnRefreshActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    &nbsp;
    ClearAll<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//เปิดปุ่ม</span>
    btnGenID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnAdd.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnEdit.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnDelete.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnSearch.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #666666; font-style: italic;">//เปิด textBox</span>
    txtSearch.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtCodePK.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbBudget.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//cbBudget.setSelectedItem(&quot;2557&quot;);</span>
    cbSex.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//cbSex.setSelectedItem(&quot;ชาย&quot;);</span>
    txtFullName.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtIDCard.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtBanID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbMoo.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//cbMoo.setSelectedItem(&quot;หมู่ที่ 1&quot;);</span>
    txtPoverty.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbHelp.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//cbHelp.setSelectedItem(&quot;เงินสงเคราะห์&quot;);</span>
    txtMoney.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    cbComment.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//cbComment.setSelectedItem(&quot;รอดำเนินการ&quot;);</span>
    txtCodeID.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Error Refresh Data!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnDeleteActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    DeleteData<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> </pre>
     
  8. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    2.แบบใช้ Class ล้วนๆ
    ================================
    ลองปรับจากการ Connect MS Access 2010 (.mdb) ==> MySQL Server ดูเอาน่ะครับ
     
    แก้ไขครั้งล่าสุดโดยผู้ดูแล: 24 มกราคม 2015
  9. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    Connect Class
    =============
     

    ไฟล์ที่แนบมา:

    • j89.png
      j89.png
      ขนาดไฟล์:
      140 KB
      เปิดดู:
      40
  10. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    MyClass Class
    =========================
    <pre class="java5" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */</span>
    <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.java.myapp</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.*</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JOptionPane</span><span style="color: #339933;">;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    *
    * @author BB
    */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyClass <span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">Connection</span> connect<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">int</span> CodePK<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> Sex<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> FullName<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> Moo<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> Poverty<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> Help<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">float</span> Money<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> CodeID<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> Budget<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> MyClass<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    connect = Connect.<span style="color: #006633;">ConnectDB</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getCodePK<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> CodePK<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setCodePK<span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">int</span> CodePK<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">CodePK</span> = CodePK<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getSex<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> Sex<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setSex<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> Sex<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Sex</span> = Sex<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getFullName<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> FullName<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setFullName<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> FullName<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">FullName</span> = FullName<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getMoo<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> Moo<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setMoo<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> Moo<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Moo</span> = Moo<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getPoverty<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> Poverty<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setPoverty<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> Poverty<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Poverty</span> = Poverty<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getHelp<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> Help<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setHelp<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> Help<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Help</span> = Help<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">float</span> getMoney<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> Money<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setMoney<span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">float</span> Money<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Money</span> = Money<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getCodeID<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> CodeID<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setCodeID<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> CodeID<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">CodeID</span> = CodeID<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getBudget<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> Budget<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setBudget<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> Budget<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Budget</span> = Budget<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getComment<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> setComment<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #003399; font-weight: bold;">Comment</span> = <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> GenID<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #006600; font-weight: bold;">boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">String</span> sql = <span style="color: #0000ff;">&quot;SELECT nvl(max(CodePK),0) FROM tblHelp&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span>sql<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">ResultSet</span> rs = pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    CodePK = rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;CodePK&quot;</span><span style="color: #009900;">)</span>+<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Error GenID!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> SearchDataUserDetails<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #006600; font-weight: bold;">boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">String</span> sql = <span style="color: #0000ff;">&quot;Select * from tblHelp &quot;</span> +
    <span style="color: #0000ff;">&quot;Where CodePK Like ?&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span>sql<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>,CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">ResultSet</span> rs = pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    CodePK = rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;CodePK&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    Sex = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Sex&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    FullName = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;FullName&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    Moo = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Moo&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    Poverty = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Poverty&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    Help = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Help&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    Money = rs.<span style="color: #006633;">getFloat</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Money&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    CodeID = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;CodeID&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    Budget = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Budget&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">Comment</span> = rs.<span style="color: #006633;">getString</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Comment&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;ค้นหาข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> InsertDataUserDetails<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #006600; font-weight: bold;">boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;INSERT INTO tblHelp&quot;</span>+
    <span style="color: #0000ff;">&quot;(CodePK,Sex,FullName,Moo,Poverty,&quot;</span> +
    <span style="color: #0000ff;">&quot;Help,Money,CodeID,Budget,Comment) &quot;</span> +
    <span style="color: #0000ff;">&quot;VALUES (?,?,?,?,?,?,?,?,?,?)&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>, CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">2</span>, Sex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">3</span>, FullName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">4</span>, Moo<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">5</span>, Poverty<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">6</span>, Help<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setFloat</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">7</span>, Money<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">8</span>, CodeID<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">9</span>, Budget<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">10</span>, <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span><span style="color: #339933;">!</span>pstmt.<span style="color: #006633;">execute</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;บันทึกข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> UpdateDataUserDetails<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #006600; font-weight: bold;">boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;UPDATE tblHelp SET &quot;</span> +
    <span style="color: #0000ff;">&quot;Sex = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;FullName = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Moo = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Poverty = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Help = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Money = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Budget = ?,&quot;</span>+
    <span style="color: #0000ff;">&quot;Comment = ? &quot;</span>+
    <span style="color: #0000ff;">&quot;WHERE CodePK = ?&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>, Sex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">2</span>, FullName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">3</span>, Moo<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">4</span>, Poverty<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">5</span>, Help<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setFloat</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">6</span>, Money<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">7</span>, Budget<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">8</span>, <span style="color: #003399; font-weight: bold;">Comment</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">9</span>, CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span><span style="color: #339933;">!</span>pstmt.<span style="color: #006633;">execute</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;แก้ไขข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> DeleteDataUserDetails<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    <span style="color: #006600; font-weight: bold;">boolean</span> status = <span style="color: #006600; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;DELETE FROM tblHelp WHERE CodePK = ?&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>, CodePK<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span><span style="color: #339933;">!</span>pstmt.<span style="color: #006633;">execute</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">{</span>
    status = <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;ลบข้อมูลผิดพลาด!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">return</span> status<span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span></pre>
     
  11. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    FormLogin.java
    ===============================
    <pre class="java5" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */</span>
    <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.java.myapp</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.KeyEvent</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Connection</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.DriverManager</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JOptionPane</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Statement</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.PreparedStatement</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.ResultSet</span><span style="color: #339933;">;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    *
    * @author BBCOM
    */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FormLogin <span style="color: #000000; font-weight: bold;">extends</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JFrame</span> <span style="color: #009900;">{</span>
    &nbsp;
    <span style="color: #003399; font-weight: bold;">Statement</span> st = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">Connection</span> connect = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">PreparedStatement</span> pstmt = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">ResultSet</span> rs = <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    * Creates new form FormLogin
    */</span>
    <span style="color: #000000; font-weight: bold;">public</span> FormLogin<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    initComponents<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setLocationRelativeTo</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    setTitle<span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;เข้าสู่โปรแกรมช่วยเหลือผู้ประสบปัญหาทางสังคม&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">try</span>
    <span style="color: #009900;">{</span>
    connect=<span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:ucanaccess://C:<span style="color: #000099; font-weight: bold;">\\</span>java<span style="color: #000099; font-weight: bold;">\\</span>dbHelp.mdb&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Connect Database Failed!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */</span>
    @<span style="color: #003399; font-weight: bold;">SuppressWarnings</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">)</span>
    <span style="color: #666666; font-style: italic;">// &lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot;Generated Code&quot;&gt; </span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> initComponents<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    &nbsp;
    txtUserName = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JTextField</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jLabel1 = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    jLabel2 = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnOK = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnRefresh = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtPassword = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JPasswordField</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    setDefaultCloseOperation<span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">WindowConstants</span>.<span style="color: #006633;">EXIT_ON_CLOSE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    jLabel1.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;User Name :&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    jLabel2.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Password :&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    btnOK.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;OK&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnOK.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    btnOKActionPerformed<span style="color: #009900;">(</span>evt<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    btnRefresh.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Refresh&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    btnRefresh.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    btnRefreshActionPerformed<span style="color: #009900;">(</span>evt<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    txtPassword.<span style="color: #006633;">addKeyListener</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">KeyAdapter</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> keyPressed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">KeyEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    txtPasswordKeyPressed<span style="color: #009900;">(</span>evt<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span> layout = <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span><span style="color: #009900;">(</span>getContentPane<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    getContentPane<span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">setLayout</span><span style="color: #009900;">(</span>layout<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    layout.<span style="color: #006633;">setHorizontalGroup</span><span style="color: #009900;">(</span>
    layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">58</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>jLabel1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">82</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>jLabel2, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">69</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">33</span>, <span style="color: #cc66cc;">33</span>, <span style="color: #cc66cc;">33</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span>, <span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">TRAILING</span>, layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>btnOK, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #cc66cc;">65</span>, <span style="color: #003399; font-weight: bold;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">18</span>, <span style="color: #cc66cc;">18</span>, <span style="color: #cc66cc;">18</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>btnRefresh<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>txtUserName<span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>txtPassword<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addContainerGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">118</span>, <span style="color: #003399; font-weight: bold;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    layout.<span style="color: #006633;">setVerticalGroup</span><span style="color: #009900;">(</span>
    layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">34</span>, <span style="color: #cc66cc;">34</span>, <span style="color: #cc66cc;">34</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">BASELINE</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>txtUserName, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>jLabel1<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">18</span>, <span style="color: #cc66cc;">18</span>, <span style="color: #cc66cc;">18</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">BASELINE</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>jLabel2<span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>txtPassword, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">50</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">(</span>layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">BASELINE</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>btnOK<span style="color: #009900;">)</span>
    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">(</span>btnRefresh<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    .<span style="color: #006633;">addContainerGap</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">48</span>, <span style="color: #003399; font-weight: bold;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
    <span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    &nbsp;
    pack<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span><span style="color: #666666; font-style: italic;">// &lt;/editor-fold&gt; </span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnRefreshActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    txtUserName.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    txtPassword.<span style="color: #006633;">setText</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> txtPasswordKeyPressed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">KeyEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>evt.<span style="color: #006633;">getKeyCode</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>==<span style="color: #003399; font-weight: bold;">KeyEvent</span>.<span style="color: #006633;">VK_ENTER</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    connect=<span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:ucanaccess://C:<span style="color: #000099; font-weight: bold;">\\</span>java<span style="color: #000099; font-weight: bold;">\\</span>dbHelp.mdb&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> sql = <span style="color: #0000ff;">&quot;select * from tblUser where UserName=? and Password=?&quot;</span><span style="color: #339933;">;</span>
    pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span>sql<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>,txtUserName.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">2</span>,txtPassword.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    rs = pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    &nbsp;
    FormAdd f1 = <span style="color: #000000; font-weight: bold;">new</span> FormAdd<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    f1.<span style="color: #006633;">setVisible</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setVisible</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    rs.<span style="color: #006633;">close</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">close</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;กรุณา Login &amp; Password อีกครั้ง&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">PLAIN_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Login Failed!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> btnOKActionPerformed<span style="color: #009900;">(</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399; font-weight: bold;">ActionEvent</span> evt<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">{</span>
    connect=<span style="color: #003399; font-weight: bold;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;jdbc:ucanaccess://C:<span style="color: #000099; font-weight: bold;">\\</span>java<span style="color: #000099; font-weight: bold;">\\</span>dbHelp.mdb&quot;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #003399; font-weight: bold;">String</span> sql = <span style="color: #0000ff;">&quot;select * from tblUser where UserName=? and Password=?&quot;</span><span style="color: #339933;">;</span>
    pstmt = connect.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">(</span>sql<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>,txtUserName.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">(</span><span style="color: #cc66cc;">2</span>,txtPassword.<span style="color: #006633;">getText</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    rs = pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">(</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    &nbsp;
    FormAdd f1 = <span style="color: #000000; font-weight: bold;">new</span> FormAdd<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    f1.<span style="color: #006633;">setVisible</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setVisible</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    rs.<span style="color: #006633;">close</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    pstmt.<span style="color: #006633;">close</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;กรุณา Login &amp; Password อีกครั้ง&quot;</span>,<span style="color: #0000ff;">&quot;รายงานสถานะ&quot;</span>,<span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">PLAIN_MESSAGE</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">Exception</span> ex<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">null</span>,<span style="color: #0000ff;">&quot;Login Failed!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>+ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    * @param args the command line arguments
    */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #006600; font-weight: bold;">void</span> main<span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">String</span> args<span style="color: #009900;">[</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #666666; font-style: italic;">/* Set the Nimbus look and feel */</span>
    <span style="color: #666666; font-style: italic;">//&lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot; Look and feel setting code (optional) &quot;&gt;</span>
    <span style="color: #666666; font-style: italic;">/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
    */</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">UIManager.<span style="color: #006633;">LookAndFeelInfo</span></span> info : javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">UIManager</span>.<span style="color: #006633;">getInstalledLookAndFeels</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">(</span><span style="color: #0000ff;">&quot;Nimbus&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">(</span>info.<span style="color: #006633;">getName</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">UIManager</span>.<span style="color: #006633;">setLookAndFeel</span><span style="color: #009900;">(</span>info.<span style="color: #006633;">getClassName</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">ClassNotFoundException</span> ex<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Logger</span>.<span style="color: #006633;">getLogger</span><span style="color: #009900;">(</span>FormLogin.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>.<span style="color: #006633;">log</span><span style="color: #009900;">(</span>java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Level</span>.<span style="color: #006633;">SEVERE</span>, <span style="color: #006600; font-weight: bold;">null</span>, ex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">InstantiationException</span> ex<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Logger</span>.<span style="color: #006633;">getLogger</span><span style="color: #009900;">(</span>FormLogin.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>.<span style="color: #006633;">log</span><span style="color: #009900;">(</span>java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Level</span>.<span style="color: #006633;">SEVERE</span>, <span style="color: #006600; font-weight: bold;">null</span>, ex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">(</span><span style="color: #003399; font-weight: bold;">IllegalAccessException</span> ex<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Logger</span>.<span style="color: #006633;">getLogger</span><span style="color: #009900;">(</span>FormLogin.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>.<span style="color: #006633;">log</span><span style="color: #009900;">(</span>java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Level</span>.<span style="color: #006633;">SEVERE</span>, <span style="color: #006600; font-weight: bold;">null</span>, ex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">(</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">UnsupportedLookAndFeelException</span> ex<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Logger</span>.<span style="color: #006633;">getLogger</span><span style="color: #009900;">(</span>FormLogin.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>.<span style="color: #006633;">log</span><span style="color: #009900;">(</span>java.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #003399; font-weight: bold;">Level</span>.<span style="color: #006633;">SEVERE</span>, <span style="color: #006600; font-weight: bold;">null</span>, ex<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #666666; font-style: italic;">//&lt;/editor-fold&gt;</span>
    &nbsp;
    <span style="color: #666666; font-style: italic;">/* Create and display the form */</span>
    java.<span style="color: #006633;">awt</span>.<span style="color: #003399; font-weight: bold;">EventQueue</span>.<span style="color: #006633;">invokeLater</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Runnable</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> run<span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
    <span style="color: #000000; font-weight: bold;">new</span> FormLogin<span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">setVisible</span><span style="color: #009900;">(</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span>
    &nbsp;
    <span style="color: #666666; font-style: italic;">// Variables declaration - do not modify </span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JButton</span> btnOK<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JButton</span> btnRefresh<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JLabel</span> jLabel1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JLabel</span> jLabel2<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JPasswordField</span> txtPassword<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399; font-weight: bold;">JTextField</span> txtUserName<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// End of variables declaration </span>
    <span style="color: #009900;">}</span></pre>
     
  12. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    FormAdd.Java
    ======================
     
  13. ledphong

    ledphong เป็นที่รู้จักกันดี สมาชิก Premium

    วันที่สมัครสมาชิก:
    28 มีนาคม 2009
    โพสต์:
    1,424
    ค่าพลัง:
    +165
    รอ Java Version ใหม่
     

    ไฟล์ที่แนบมา:

    • 1.png
      1.png
      ขนาดไฟล์:
      185.9 KB
      เปิดดู:
      38
  14. sontaya31

    sontaya31 สมาชิกใหม่

    วันที่สมัครสมาชิก:
    12 มีนาคม 2017
    โพสต์:
    1
    ค่าพลัง:
    +0
    ดีมากๆเลยครับ :) พอเห็นโค้ดยาวๆ เสร็จเลยครับ งง เป็นไก่ตาแตกเลย ขอบคุณครับ
     

แชร์หน้านี้

Loading...