📄 frm_add_edit_supplier.java
字号:
JTFZipCode.setBounds(110,204,200,20);
JTFZipCode.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLZipCode);
JPContainer.add(JTFZipCode);
//-- Add Country Input Field
JLCountry.setBounds(5,226,105,20);
JLCountry.setFont(new Font("Dialog",Font.PLAIN,12));
JCBCountry.setBounds(110,226,200,20);
JCBCountry.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLCountry);
JPContainer.add(JCBCountry);
//-- Add Phone Input Field
JLPhone.setBounds(5,248,105,20);
JLPhone.setFont(new Font("Dialog",Font.PLAIN,12));
JTFPhone.setBounds(110,248,200,20);
JTFPhone.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLPhone);
JPContainer.add(JTFPhone);
//-- Add Fax Input Field
JLFax.setBounds(5,270,105,20);
JLFax.setFont(new Font("Dialog",Font.PLAIN,12));
JTFFax.setBounds(110,270,200,20);
JTFFax.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLFax);
JPContainer.add(JTFFax);
//-- Add Website Input Field
JLWebsite.setBounds(5,292,105,20);
JLWebsite.setFont(new Font("Dialog",Font.PLAIN,12));
JTFWebsite.setBounds(110,292,200,20);
JTFWebsite.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLWebsite);
JPContainer.add(JTFWebsite);
//******************** End adding of input field
//-- Add the JBUpdate
JBUpdate.setBounds(5,340,105,25);
JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12));
JBUpdate.setMnemonic(KeyEvent.VK_A);
JBUpdate.addActionListener(JBActionListener);
JBUpdate.setActionCommand("update");
JPContainer.add(JBUpdate);
//-- Add the JBReset
JBReset.setBounds(112,340,99,25);
JBReset.setFont(new Font("Dialog", Font.PLAIN, 12));
JBReset.setMnemonic(KeyEvent.VK_R);
JBReset.addActionListener(JBActionListener);
JBReset.setActionCommand("reset");
JPContainer.add(JBReset);
//-- Add the JBCancel
JBCancel.setBounds(212,340,99,25);
JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12));
JBCancel.setMnemonic(KeyEvent.VK_C);
JBCancel.addActionListener(JBActionListener);
JBCancel.setActionCommand("cancel");
JPContainer.add(JBCancel);
getContentPane().add(JPContainer);
setSize(325,405);
setResizable(false);
setLocation((screen.width - 325)/2,((screen.height-405)/2));
}
private boolean RequiredFieldEmpty(){
if(JTFId.getText().equals("") || JTFName.getText().equals("")){
JOptionPane.showMessageDialog(null,"Some required fields is/are empty.\nPlease check it and try again.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE);
JTFId.requestFocus();
return true;
}else{
return false;
}
}
private void clearFields(){
JTFId.setText("");
JTFName.setText("");
JTFContName.setText("");
JTFContTitle.setText("");
JTFAddr.setText("");
JTFCity.setText("");
JTFState.setText("");
JTFZipCode.setText("");
JCBCountry.setSelectedIndex(0);
JTFPhone.setText("");
JTFFax.setText("");
JTFWebsite.setText("");
}
ActionListener JBActionListener = new ActionListener(){
public void actionPerformed(ActionEvent e){
String srcObj = e.getActionCommand();
if(srcObj=="update"){
if(RequiredFieldEmpty()==false){
if(ADDING_STATE == true){
try{
stAES.executeUpdate("INSERT INTO tblSupplier(SupplierID,CompanyName,ContactName,ContactTitle,Address,CityTown,StateProvince,ZipCode,Country,Phone,Fax,Website) " +
"VALUES ('" +
JTFId.getText() + "', '" +
JTFName.getText() + "', '" +
JTFContName.getText() + "', '" +
JTFContTitle.getText() + "', '" +
JTFAddr.getText() + "', '" +
JTFCity.getText() + "', '" +
JTFState.getText() + "', '" +
JTFZipCode.getText() + "', '" +
JCBCountry.getSelectedItem().toString() + "', '" +
JTFPhone.getText() + "', '" +
JTFFax.getText() + "', '" +
JTFWebsite.getText() +
"')");
// Start Display the new record
int total =0;
total = clsPublicMethods.getMaxNum("SELECT * FROM tblSupplier ORDER BY SupplierIndex ASC",cnAES,"SupplierIndex");
if(total != 0){
FrmSupplier.reloadRecord("SELECT * FROM tblSupplier WHERE SupplierIndex = " + total + " ORDER BY CompanyName ASC");
}else{
FrmSupplier.reloadRecord("SELECT * FROM tblSupplier ORDER BY CompanyName ASC");
}
total =0;
// End Display the new record
JOptionPane.showMessageDialog(null,"New record has been successfully added.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE);
String ObjButtons[] = {"Yes","No"};
int PromptResult = JOptionPane.showOptionDialog(null,"Do you want add another record?","Naparansoft Inventory System",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null,ObjButtons,ObjButtons[0]);
if(PromptResult==0){
clearFields();
JTFId.requestFocus(true);
}else{
dispose();
}
}catch(SQLException sqlEx){
System.out.println(sqlEx.getMessage());
}
}else{
try{
String RowIndex;
RowIndex = rsAES.getString("SupplierIndex");
stAES.executeUpdate("UPDATE tblSupplier SET SupplierID = '" +
JTFId.getText() + "', CompanyName = '" +
JTFName.getText() + "', ContactName = '" +
JTFContName.getText() + "', ContactTitle = '" +
JTFContTitle.getText() + "', Address = '" +
JTFAddr.getText() + "', CityTown = '" +
JTFCity.getText() + "', StateProvince = '" +
JTFState.getText() + "', ZipCode = '" +
JTFZipCode.getText() + "', Country = '" +
JCBCountry.getSelectedItem().toString() + "', Phone = '" +
JTFPhone.getText() + "', Fax = '" +
JTFFax.getText() + "', Website = '" +
JTFWebsite.getText() +
"' WHERE SupplierIndex = " + RowIndex);
FrmSupplier.reloadRecord("SELECT * FROM tblSupplier WHERE SupplierIndex = " + RowIndex + " ORDER BY CompanyName ASC");
JOptionPane.showMessageDialog(null,"Changes in the record has been successfully save.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE);
RowIndex="";
dispose();
}catch(SQLException sqlEx){
System.out.println(sqlEx.getMessage());
}
}
}
}else if(srcObj=="reset"){
clearFields();
}else if(srcObj=="cancel"){
dispose();
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -