📄 adddepotframe.java
字号:
/*
* addDepotFrame.java
*
* Created on 2007年6月18日, 下午6:55
*/
package frames;
import java.util.*;
import javax.swing.*;
import plugin.*;
import module.*;
import helper.*;
import jack.*;
/**
*
* @author zzx
*/
/*添加修改仓库信息窗口*/
public class addDepotFrame extends javax.swing.JInternalFrame {
String type=new String("insert"); //标识操作类型
/** Creates new form addDepotFrame */
/**
* 构造函数
* 无参的构造函数,用于添加仓库信息的操作
*/
public addDepotFrame() {
initComponents();
setTitle("添加仓库");
}
/**
* 构造函数
* 有参的构造函数,用于仓库信息的修改操作
*/
public addDepotFrame(String depotID,String depotName,String location,String principal,String tel,String remark){
initComponents();
setTitle("修改仓库");
addButton.setText("修改");
depotIDTextField.setText(depotID);
depotIDTextField.setEditable(false); //更新时编号不可改变
depotNameTextField.setText(depotName);
locationTextField.setText(location);
principalTextField.setText(principal);
telTextField.setText(tel);
remarkTextArea.setText(remark);
type="update";
}
/**
* 构造函数
* 用DepotInfo变量构造函数,用于仓库信息的修改操作
*/
public addDepotFrame(DepotInfo di){
initComponents();
setTitle("修改仓库");
addButton.setText("修改");
depotIDTextField.setText(di.getDepotID());
depotIDTextField.setEditable(false); //更新时编号不可改变
depotNameTextField.setText(di.getDepotName());
locationTextField.setText(di.getLocation());
principalTextField.setText(di.getPrincipal());
telTextField.setText(di.geTtel());
remarkTextArea.setText(di.getRemark());
type="update";
}
/** 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() {
jLabel1 = new javax.swing.JLabel();
depotIDTextField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
depotNameTextField = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
locationTextField = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
telTextField = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
remarkTextArea = new javax.swing.JTextArea();
addButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
principalTextField = new javax.swing.JTextField();
setClosable(true);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
jLabel1.setText("\u4ed3\u5e93\u7f16\u53f7\uff1a");
jLabel2.setText("\u4ed3\u5e93\u540d\u79f0\uff1a");
jLabel3.setText("\u4ed3\u5e93\u4f4d\u7f6e\uff1a");
jLabel4.setText("\u7535\u8bdd\uff1a");
jLabel5.setText("\u5907\u6ce8\uff1a");
remarkTextArea.setColumns(20);
remarkTextArea.setRows(5);
jScrollPane1.setViewportView(remarkTextArea);
addButton.setText("\u6dfb\u52a0");
addButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addButtonActionPerformed(evt);
}
});
cancelButton.setText("\u53d6\u6d88");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
jLabel6.setText("\u8d1f\u8d23\u4eba\uff1a");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(depotIDTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(jLabel2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(depotNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(jLabel3)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(14, 14, 14)
.add(addButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 51, Short.MAX_VALUE)
.add(cancelButton)
.add(47, 47, 47))
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(locationTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel6)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(principalTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(24, 24, 24)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel4)
.add(jLabel5))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
.add(telTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(depotIDTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(depotNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(locationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel6)
.add(principalTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(telTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(cancelButton)
.add(addButton))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO 将在此处添加您的处理代码:
this.dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
// TODO 将在此处添加您的处理代码:
if(depotIDTextField.getText().trim().equals("")||depotNameTextField.getText().trim().equals("")
||locationTextField.getText().trim().equals("")){//仓库编号,名称,位置有一项空,则弹出提示框
JOptionPane.showMessageDialog(this, "请填写完整必要的信息", "Error",JOptionPane.ERROR_MESSAGE);
}else{
if(type.equals("insert")){//判断为插入操作
DepotOperate depoto=new DepotOperate(Resource.getDBResource());
DepotInfo di=new DepotInfo(depotIDTextField.getText(),depotNameTextField.getText(),
locationTextField.getText(),principalTextField.getText(),telTextField.getText(),
remarkTextArea.getText()); //用窗体的信息构造一个仓库信息类
if(depoto.insert(di)==-1){ //插入失败
JOptionPane.showMessageDialog(this, "添加失败", "Error",JOptionPane.ERROR_MESSAGE);
}
else{ //插入成功
JOptionPane.showMessageDialog(this, "添加成功", "sucessful",JOptionPane.OK_OPTION);
this.dispose();
}
}
if(type.equals("update")){ //判断为更新操作
DepotOperate depoto=new DepotOperate(Resource.getDBResource());
DepotInfo di=new DepotInfo(depotIDTextField.getText(),depotNameTextField.getText(),
locationTextField.getText(),principalTextField.getText(),telTextField.getText(),
remarkTextArea.getText()); //用窗体的信息构造一个仓库信息类
if(depoto.update(di)==-1){ //更新失败
JOptionPane.showMessageDialog(this, "更新失败", "Error",JOptionPane.ERROR_MESSAGE);
}else{ //更新成功
JOptionPane.showMessageDialog(this, "更新成功", "sucessful",JOptionPane.OK_OPTION);
this.dispose();
}
}
}
}//GEN-LAST:event_addButtonActionPerformed
/**
* @param args the command line arguments
*/
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton addButton;
private javax.swing.JButton cancelButton;
private javax.swing.JTextField depotIDTextField;
private javax.swing.JTextField depotNameTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField locationTextField;
private javax.swing.JTextField principalTextField;
private javax.swing.JTextArea remarkTextArea;
private javax.swing.JTextField telTextField;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -