private void btn_saveActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_saveActionPerformed
   // TODO add your handling code here:
   int selectRow = tblProduct.getSelectedRow();
   OptionGroup_Controller group = new OptionGroup_Controller();
   if (selectRow > -1) {
     JOptionPane.showMessageDialog(this, "รายการนี้มีการบันไว้แล้ว");
     option.selectAll();
   } else {
     String code = pcode.getText();
     String opt = option.getText();
     if (code.trim().equals("")) {
       JOptionPane.showMessageDialog(this, "กรุณาระบุรหัสกลุ่มสินค้า");
       pcode.selectAll();
       pcode.requestFocus();
     } else if (pdesc.getText().equals("**** GroupFile Error ****")) {
       JOptionPane.showMessageDialog(this, "รหัสสินค้าไม่ถูกต้อง");
       pcode.requestFocus();
     } else if (opt.trim().equals("")) {
       JOptionPane.showMessageDialog(this, "กรุณาระบุรายการ Option");
       option.requestFocus();
     } else {
       if (group.insertOption(code, opt)) {
         clearForm();
         setDataToGrid(group.getOptionDetail(code));
       }
     }
   }
 } // GEN-LAST:event_btn_saveActionPerformed
 private void pcodeKeyReleased(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_pcodeKeyReleased
   // TODO add your handling code here:
   String code = pcode.getText();
   int tblsize = tblProduct_model.getRowCount();
   for (int i = 0; i < tblsize; i++) {
     tblProduct_model.removeRow(0);
   }
   pdesc.setText("");
   if (!code.trim().equals("")) {
     OptionGroup_Controller group = new OptionGroup_Controller();
     String groupName = group.seekGroup(code);
     if (groupName != null && !groupName.equals("")) {
       pdesc.setText(groupName);
       setDataToGrid(group.getOptionDetail(code));
     } else {
       pdesc.setText("**** GroupFile Error ****");
     }
   }
   if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
     if (!pdesc.getText().equals("**** GroupFile Error ****")
         && !pdesc.getText().trim().equals("")) {
       option.requestFocus();
     }
   }
 } // GEN-LAST:event_pcodeKeyReleased
 private void bnt_removeActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_bnt_removeActionPerformed
   int row = tblProduct.getSelectedRow();
   if (row > -1) {
     int confirm =
         JOptionPane.showConfirmDialog(
             this, "คุณต้องการลบข้อมูลรายการนี้หรือไม่...?", "Confirm", JOptionPane.YES_NO_OPTION);
     if (confirm == JOptionPane.YES_OPTION) {
       String code = tblProduct_model.getValueAt(row, 0).toString();
       String name = tblProduct_model.getValueAt(row, 1).toString();
       OptionGroup_Controller group = new OptionGroup_Controller();
       if (group.removeOptionDetail(code, name)) {
         tblProduct_model.removeRow(row);
       }
     }
   }
 } // GEN-LAST:event_bnt_removeActionPerformed