📄 frm_add_edit_supplier.java
字号:
package MainForm;
/*
********************************************************************************
* *
* Note: *
* This is not intended to used in a big business because this system was *
* created for small business only.
* *
********************************************************************************
*/
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class frm_add_edit_supplier extends JDialog{
JButton JBUpdate = new JButton(new ImageIcon("images/save.png"));
JButton JBReset = new JButton("Reset",new ImageIcon("images/reset.png"));
JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png"));
JLabel JLPic1 = new JLabel();
JLabel JLBanner = new JLabel("Please fill-up all the required fields.");
JLabel JLId = new JLabel("Supplier ID:");
JLabel JLName = new JLabel("Supplier Name:");
JLabel JLContName = new JLabel("Contact Name:");
JLabel JLContTitle = new JLabel("Contact Title:");
JLabel JLAddr = new JLabel("Address:");
JLabel JLCity = new JLabel("City/Town:");
JLabel JLState = new JLabel("State/Province:");
JLabel JLZipCode = new JLabel("Zip Code:");
JLabel JLCountry = new JLabel("Country:");
JLabel JLPhone = new JLabel("Phone:");
JLabel JLFax = new JLabel("Fax:");
JLabel JLWebsite = new JLabel("Website:");
JTextField JTFId = new JTextField();
JTextField JTFName = new JTextField();
JTextField JTFContName = new JTextField();
JTextField JTFContTitle = new JTextField();
JTextField JTFAddr = new JTextField();
JTextField JTFCity = new JTextField();
JTextField JTFState = new JTextField();
JTextField JTFZipCode = new JTextField();
JComboBox JCBCountry;
JTextField JTFPhone = new JTextField();
JTextField JTFFax = new JTextField();
JTextField JTFWebsite = new JTextField();
Connection cnAES;
Statement stAES;
ResultSet rsAES;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE;
public frm_add_edit_supplier(boolean ADD_STATE,JFrame OwnerForm,Connection srcCN,String srcSQL){
super(OwnerForm,true);
cnAES = srcCN;
ADDING_STATE = ADD_STATE;
try{
stAES = cnAES.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
}catch( SQLException sqlEx){
System.out.println("\nERROR IN frm_add_edit_supplier(frm_add_edit_supplier):" + sqlEx + "\n");
}
JCBCountry = clsPublicMethods.fillCombo("SELECT * FROM tblCountry",cnAES,"Name");
if(ADD_STATE==true){
JLPic1.setIcon(new ImageIcon("images/bNew.png"));
setTitle("Add New Supplier");
JBUpdate.setText("Update");
}else{
JLPic1.setIcon(new ImageIcon("images/bModify.png"));
setTitle("Modify Supplier");
JBUpdate.setText("Save");
try{
rsAES = stAES.executeQuery(srcSQL);
rsAES.next();
JTFId.setText("" + rsAES.getString("SupplierID"));
JTFName.setText("" + rsAES.getString("CompanyName"));
JTFContName.setText("" + rsAES.getString("ContactName"));
JTFContTitle.setText("" + rsAES.getString("ContactTitle"));
JTFAddr.setText("" + rsAES.getString("Address"));
JTFCity.setText("" + rsAES.getString("CityTown"));
JTFState.setText("" + rsAES.getString("StateProvince"));
JTFZipCode.setText("" + rsAES.getString("ZipCode"));
//searchInComboPos
JCBCountry.setSelectedItem("" + rsAES.getString("Country"));
JTFPhone.setText("" + rsAES.getString("Phone"));
JTFFax.setText("" + rsAES.getString("Fax"));
JTFWebsite.setText("" + rsAES.getString("Website"));
}catch(SQLException sqlEx){
System.out.println(sqlEx.getMessage());
}
}
JPanel JPContainer = new JPanel();
JPContainer.setLayout(null);
//-- Add the JLPic1
JLPic1.setBounds(5,5,32,32);
JPContainer.add(JLPic1);
//-- Add the JLBanner
JLBanner.setBounds(55,5,268,48);
JLBanner.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLBanner);
//******************** Start adding of input field
//-- Add Id Input Field
JLId.setBounds(5,50,105,20);
JLId.setFont(new Font("Dialog",Font.PLAIN,12));
JTFId.setBounds(110,50,200,20);
JTFId.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLId);
JPContainer.add(JTFId);
//-- Add Name Input Field
JLName.setBounds(5,72,105,20);
JLName.setFont(new Font("Dialog",Font.PLAIN,12));
JTFName.setBounds(110,72,200,20);
JTFName.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLName);
JPContainer.add(JTFName);
//-- Add Contact Name Input Field
JLContName.setBounds(5,94,105,20);
JLContName.setFont(new Font("Dialog",Font.PLAIN,12));
JTFContName.setBounds(110,94,200,20);
JTFContName.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLContName);
JPContainer.add(JTFContName);
//-- Add Contact Title Input Field
JLContTitle.setBounds(5,116,105,20);
JLContTitle.setFont(new Font("Dialog",Font.PLAIN,12));
JTFContTitle.setBounds(110,116,200,20);
JTFContTitle.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLContTitle);
JPContainer.add(JTFContTitle);
//-- Add Address Input Field
JLAddr.setBounds(5,138,105,20);
JLAddr.setFont(new Font("Dialog",Font.PLAIN,12));
JTFAddr.setBounds(110,138,200,20);
JTFAddr.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLAddr);
JPContainer.add(JTFAddr);
//-- Add City Input Field
JLCity.setBounds(5,160,105,20);
JLCity.setFont(new Font("Dialog",Font.PLAIN,12));
JTFCity.setBounds(110,160,200,20);
JTFCity.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLCity);
JPContainer.add(JTFCity);
//-- Add State/Province Input Field
JLState.setBounds(5,182,105,20);
JLState.setFont(new Font("Dialog",Font.PLAIN,12));
JTFState.setBounds(110,182,200,20);
JTFState.setFont(new Font("Dialog",Font.PLAIN,12));
JPContainer.add(JLState);
JPContainer.add(JTFState);
//-- Add Zip Code Input Field
JLZipCode.setBounds(5,204,105,20);
JLZipCode.setFont(new Font("Dialog",Font.PLAIN,12));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -