📄 accretion_dialog.java
字号:
/*
* accretion_Dialog.java
*
* Created on 2007年4月29日, 下午6:44
*
*此功能是用来实现添加设备
*/
package com.cn.szhaccp.set;
import com.cn.szhaccp.landing.ToCenter;
import com.cn.szhaccp.sill.*;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/
public class accretion_Dialog extends javax.swing.JDialog {
sillClass sill;
ToCenter tocenter;
/** Creates new form accretion_Dialog */
public accretion_Dialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
tocenter = new ToCenter();
tocenter.SetDialogToCenter(this);
}
public accretion_Dialog(java.awt.Frame parent,boolean modal,sillClass sill){
this(parent,modal);
this.sill = sill;
}
/** 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();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
statetext = new javax.swing.JComboBox();
jLabel8 = new javax.swing.JLabel();
Nametext = new javax.swing.JTextField();
sorttext = new javax.swing.JTextField();
modeltext = new javax.swing.JTextField();
merittext = new javax.swing.JTextField();
buydatetext = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("\u6dfb\u52a0\u8d44\u4ea7");
jLabel1.setText("\u8bbe\u5907\u540d\u79f0\uff1a");
jLabel3.setText("\u8bbe\u5907\u79cd\u7c7b\uff1a");
jLabel4.setText("\u8bbe\u5907\u578b\u53f7\uff1a");
jLabel5.setText("\u8bbe\u5907\u4ef7\u503c\uff1a");
jLabel6.setText("\u8d2d\u4e70\u65e5\u671f\uff1a");
jLabel7.setText("\u8d44\u4ea7\u72b6\u6001\uff1a");
statetext.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3" }));
jLabel8.setText("(1-\u6b63\u5e38,2-\u7ef4\u4fee,3-\u62a5\u5e9f)");
jButton1.setText("\u6dfb \u52a0");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("\u53d6 \u6d88");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
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(50, 50, 50)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel5)
.add(jLabel1)
.add(jLabel3)
.add(jLabel4)
.add(jLabel6)
.add(jLabel7))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(statetext, 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(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 132, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, buydatetext)
.add(org.jdesktop.layout.GroupLayout.LEADING, merittext)
.add(org.jdesktop.layout.GroupLayout.LEADING, modeltext)
.add(org.jdesktop.layout.GroupLayout.LEADING, sorttext)
.add(org.jdesktop.layout.GroupLayout.LEADING, Nametext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))))
.add(layout.createSequentialGroup()
.add(jButton1)
.add(75, 75, 75)
.add(jButton2)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 178, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(264, 264, 264)
.add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 195, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(15, 15, 15)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(93, 93, 93)
.add(jLabel2))
.add(layout.createSequentialGroup()
.add(8, 8, 8)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(Nametext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(sorttext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(modeltext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(merittext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel6)
.add(buydatetext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(20, 20, 20)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel7)
.add(statetext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel8))
.add(30, 30, 30)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2))
.addContainerGap(26, Short.MAX_VALUE))
);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-330)/2, (screenSize.height-332)/2, 330, 332);
}// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
add();
}//GEN-LAST:event_jButton1ActionPerformed
public void add(){
String Name = Nametext.getText();
String sort = sorttext.getText();
String model = modeltext.getText();
double merit=0;
try{
merit = Double.parseDouble(merittext.getText());
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "请正确输入设备价值,价值必须为数字!!!", "错误提示", JOptionPane.ERROR_MESSAGE);
merittext.grabFocus();
return;
}
String buydate = buydatetext.getText();
String state = (String)statetext.getSelectedItem();
String username = "";
String annotation = "";
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
if(Name.equalsIgnoreCase("") || sort.equalsIgnoreCase("") || model.equalsIgnoreCase("") || buydate.equalsIgnoreCase("")){
JOptionPane.showMessageDialog(this,"请正确完整输入!!!","错误提示",JOptionPane.ERROR_MESSAGE);
}else{
try {
open.accretion_record(Name,sort,model,merit,buydate,state,username);
JOptionPane.showMessageDialog(this, "添加成功!感谢您的使用!!", "添加提示", JOptionPane.INFORMATION_MESSAGE);
DatabaseConnection dbc = new DatabaseConnection();
MainFrame.rm.setResult(dbc.getRs());
this.dispose();
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, ex.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
}
}
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JTextField Nametext;
private javax.swing.JTextField buydatetext;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
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.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField merittext;
private javax.swing.JTextField modeltext;
private javax.swing.JTextField sorttext;
private javax.swing.JComboBox statetext;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -