📄 supplierframe.java
字号:
/*
* EmployeeFrame.java
*
* Created on 2007年5月16日, 下午1:34
* 陈诗昭 ,
*/
package form;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import table.Supplier;
import task.HandleSupplier;
import util.ConstentUtil;
/**
*
* @author 下雪天
*/
public class SupplierFrame extends javax.swing.JInternalFrame {
/** Creates new form EmployeeFrame */
private boolean add_pasre=false;//添加按钮选择
private boolean reset_pasre=false;//修改按钮选择
HandleSupplier hu=new HandleSupplier();
Supplier s=new Supplier();
ArrayList v=new ArrayList();
public SupplierFrame() {
super("供应商资料",false,false,false,true);
initComponents();
//初始化时,将所有的文本框设为不可编辑
settxt();
databind();
}
private void showtable(){
String[] theader={"编号","名称","负责人","职务","移动电话","进货员工","地址","最近进货日期"};
int j=0;
String[][] tdata=new String[v.size()][8];
for(int i=0;i<v.size();i++){
Supplier s=new Supplier();
s=(Supplier)v.get(i);
tdata[i][0]=s.getSupplierID();
tdata[i][1]=s.getSupplierName();
tdata[i][2]=s.getOwerPost();
tdata[i][3]=s.getOwer();
tdata[i][4]=s.getPhone();
tdata[i][5]=s.getMobilePhone();
tdata[i][6]=s.getSupplierAddress();
if(s.getLastPurchaseDate()!=null)
tdata[i][7]=s.getLastPurchaseDate().toString();
}
jTable1.setModel(new DefaultTableModel(tdata,theader));
}
public void settxt(){
txtSupplierID.setEditable(false);
txtSupplierName.setEditable(false);
txtMobilePhone.setEditable(false);
txtOwer.setEditable(false);
txtOwerPost.setEditable(false);
txtPhone.setEditable(false);
txtSupplierAddress.setEditable(false);
}
public void dissettxt()
{
txtMobilePhone.setEditable(true);
txtSupplierName.setEditable(true);
txtOwer.setEditable(true);
txtOwerPost.setEditable(true);
txtPhone.setEditable(true);
txtSupplierAddress.setEditable(true);
}
//将所有文本框置为空
public void clear(){
txtSupplierID.setText("");//.setText("");
txtSupplierName.setText("");
txtOwer.setText("");
txtOwerPost.setText("");
txtPhone.setText("");
txtMobilePhone.setText("");
txtSupplierAddress.setText("");
}
private void databind(){
try {
v=hu.findAll();
} finally {
}
showtable();
}
private void save(){
s.setSupplierID(txtSupplierID.getText());
s.setSupplierName(txtSupplierName.getText());
s.setOwer(txtOwer.getText());
s.setOwerPost(txtOwerPost.getText());
s.setPhone(txtPhone.getText());
s.setMobilePhone(txtMobilePhone.getText());
s.setSupplierAddress(txtSupplierAddress.getText());
hu.save(s);
}
private void rework(){
s.setSupplierID(txtSupplierID.getText().trim());
s.setSupplierName(txtSupplierName.getText().trim());
s.setOwer(txtOwer.getText().trim());
s.setOwerPost(txtOwerPost.getText().trim());
s.setPhone(txtPhone.getText().trim());
s.setMobilePhone(txtMobilePhone.getText().trim());
s.setSupplierAddress(txtSupplierAddress.getText().trim());
hu.update(s);
}
private void reset(){
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
JPane2 = new javax.swing.JPanel();
jButton5 = new javax.swing.JButton();
EixtButton = new javax.swing.JButton();
AddButton = new javax.swing.JButton();
ReworkButton = new javax.swing.JButton();
DeleteButton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtSupplierID = new javax.swing.JTextField();
txtOwerPost = new javax.swing.JTextField();
txtSupplierName = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
txtMobilePhone = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
txtSupplierAddress = new javax.swing.JTextField();
txtOwer = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
txtPhone = new javax.swing.JTextField();
Buttonsave = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
JPane2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/daying.gif")));
EixtButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/exit.gif")));
EixtButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
EixtButtonActionPerformed(evt);
}
});
AddButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/addgy.gif")));
AddButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AddButtonActionPerformed(evt);
}
});
ReworkButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/xiugaigy.gif")));
ReworkButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ReworkButtonActionPerformed(evt);
}
});
DeleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/shanchu.gif")));
DeleteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DeleteButtonActionPerformed(evt);
}
});
jLabel1.setText("\u4f9b\u8d27\u5546\u7f16\u53f7\uff1a");
jLabel2.setText("\u8d1f\u8d23\u4eba\u804c\u52a1\uff1a");
jLabel3.setText("\u8d1f\u8d23\u4eba\u540d\u79f0\uff1a");
jLabel4.setText("\u79fb\u52a8\u7535\u8bdd\uff1a");
jLabel5.setText("\u5ba2\u6237\u5730\u5740\uff1a");
jLabel6.setText("\u4f9b\u8d27\u5546\u540d\u79f0\uff1a");
jLabel7.setText("\u7535\u8bdd\uff1a");
Buttonsave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save.gif")));
Buttonsave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ButtonsaveActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout JPane2Layout = new org.jdesktop.layout.GroupLayout(JPane2);
JPane2.setLayout(JPane2Layout);
JPane2Layout.setHorizontalGroup(
JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, JPane2Layout.createSequentialGroup()
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(JPane2Layout.createSequentialGroup()
.add(37, 37, 37)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(JPane2Layout.createSequentialGroup()
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel4)
.add(jLabel5)
.add(jLabel2))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(txtSupplierAddress, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, txtMobilePhone)
.add(org.jdesktop.layout.GroupLayout.LEADING, txtSupplierID)
.add(org.jdesktop.layout.GroupLayout.LEADING, txtOwerPost, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))))))
.add(JPane2Layout.createSequentialGroup()
.add(76, 76, 76)
.add(AddButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(ReworkButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(JPane2Layout.createSequentialGroup()
.add(6, 6, 6)
.add(DeleteButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 194, Short.MAX_VALUE)
.add(Buttonsave)
.add(2, 2, 2))
.add(JPane2Layout.createSequentialGroup()
.add(112, 112, 112)
.add(JPane2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -