jButtonAdd.setBounds(685, 7, 126, 32);
jButtonAdd.setEnabled(Common.userList.getUser(Common.sessionID).isModuleAllowed("FRM_ADMIN_MATERIAL_CUST_DATA_ADD"));
jButtonAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
JDBMaterialCustomerData m = new JDBMaterialCustomerData(Common.selectedHostID, Common.sessionID);
JDBCustomer u = new JDBCustomer(Common.selectedHostID, Common.sessionID);
LinkedList<JDBCustomer> custList = u.getCustomers();
String[] customerList = new String[custList.size()];
for (int x = 0; x < custList.size(); x++)
{
customerList[x] = custList.get(x).getID();
}
lcustomer = (String) JOptionPane.showInputDialog(Common.mainForm, lang.get("dlg_Customer_Input"), lang.get("btn_Select"), JOptionPane.PLAIN_MESSAGE, Common.icon_confirm, customerList, customerList[0]);
if (lcustomer != null)
{
if (lcustomer.equals("") == false)
{
lcustomer = lcustomer.toUpperCase();
if (u.isValidCustomer(lcustomer))
{
JDBDataIDs di = new JDBDataIDs(Common.selectedHostID, Common.sessionID);
LinkedList<JDBDataIDs> idList = di.getDataIDs();
String[] dataIDList = new String[idList.size()];
for (int x = 0; x < idList.size(); x++)
{
dataIDList[x] = idList.get(x).getID();
}
ldataid = (String) JOptionPane.showInputDialog(Common.mainForm, lang.get("dlg_Data_ID_Input"), lang.get("btn_Select"), JOptionPane.QUESTION_MESSAGE, Common.icon_confirm, dataIDList, dataIDList[0]);
if (ldataid != null)
{
if (ldataid.equals("") == false)
{
ldataid = ldataid.toUpperCase();
m.setMaterial(lmaterial);
m.setCustomerID(lcustomer);
m.setDataID(ldataid);
if (m.isValid() == true)
{
if (m.isValidMaterialCustomerData() == false)
{
m.create();
}
JLaunchMenu.runDialog("FRM_ADMIN_MATERIAL_CUST_DATA_EDIT", lmaterial, lcustomer, ldataid);
populateList(lmaterial);
}
}
}
} else
{
JOptionPane.showMessageDialog(Common.mainForm, "Invalid Customer [" + lcustomer + "] does not exist", lang.get("dlg_Error"), JOptionPane.ERROR_MESSAGE);
}
}
}
}
});
}
{
jButtonEdit = new JButton4j(Common.icon_edit);
jDesktopPane1.add(jButtonEdit);
jButtonEdit.setText(lang.get("btn_Edit"));
jButtonEdit.setMnemonic(lang.getMnemonicChar());
jButtonEdit.setBounds(685, 35, 126, 32);
jButtonEdit.setEnabled(Common.userList.getUser(Common.sessionID).isModuleAllowed("FRM_ADMIN_MATERIAL_CUST_DATA_EDIT"));
jButtonEdit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
editRecord();
}
});
}
{
jButtonDelete = new JButton4j(Common.icon_delete);
jDesktopPane1.add(jButtonDelete);
jButtonDelete.setText(lang.get("btn_Delete"));
jButtonDelete.setMnemonic(lang.getMnemonicChar());
jButtonDelete.setBounds(685, 63, 126, 32);
jButtonDelete.setEnabled(Common.userList.getUser(Common.sessionID).isModuleAllowed("FRM_ADMIN_MATERIAL_CUST_DATA_DELETE"));
jButtonDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt)
{
int row = jTable1.getSelectedRow();
if (row >= 0)
{
lcustomer = jTable1.getValueAt(row, JDBMaterialCustomerDataTableModel.Material_Col).toString();
lcustomer = jTable1.getValueAt(row, JDBMaterialCustomerDataTableModel.Customer_Col).toString();
ldataid = jTable1.getValueAt(row, JDBMaterialCustomerDataTableModel.Data_ID_Col).toString();
int question = JOptionPane.showConfirmDialog(Common.mainForm, "Delete Material [" + lmaterial + "] Customer [" + lcustomer + "] Data ID [" + ldataid + "] ?", lang.get("dlg_Confirm"), JOptionPane.YES_NO_OPTION, 0,
Common.icon_confirm);
if (question == 0)
{
JDBMaterialCustomerData m = new JDBMaterialCustomerData(Common.selectedHostID, Common.sessionID);
m.setMaterial(lmaterial);
m.setCustomerID(lcustomer);
m.setDataID(ldataid);
boolean result = m.delete();
if (result == false)
{
JUtility.errorBeep();
JOptionPane.showMessageDialog(Common.mainForm, m.getErrorMessage(), "Delete error Material Customer Data [" + lmaterial + "] Customer [" + lcustomer + "] Data ID [" + ldataid + "]",
JOptionPane.WARNING_MESSAGE);
} else
{
populateList(lmaterial);
}