📄 demesne_dialog.java
字号:
/*
* demesne_Dialog.java
*
* Created on 2007年5月9日, 下午4:53
*/
package com.cn.szhaccp.sill;
import com.cn.szhaccp.landing.ToCenter;
import com.cn.szhaccp.set.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.SQLException;
import java.util.Calendar;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
/**
*
* @author Administrator
*/
public class demesne_Dialog extends javax.swing.JDialog {
sillClass sill = new sillClass();
ToCenter tocenter;
public demesne_Dialog(){
}
/** Creates new form demesne_Dialog */
public demesne_Dialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
tocenter = new ToCenter();
tocenter.SetDialogToCenter(this);
settext();
}
public demesne_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() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
annotationtext = new javax.swing.JTextArea();
idtext = new javax.swing.JTextField();
nametext = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
purposetext = new javax.swing.JTextArea();
Nametext = new javax.swing.JTextField();
sorttext = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
IDtext = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("\u5feb\u901f\u9886\u7528");
jButton1.setText("\u9886 \u7528");
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);
}
});
jLabel5.setText("\u501f\u7528\u7528\u9014\uff1a");
jLabel4.setText("\u804c\u5458\u59d3\u540d\uff1a");
jLabel3.setText("\u804c\u5458 ID\uff1a");
jLabel2.setText("\u8bbe\u5907\u540d\u79f0\uff1a");
jLabel1.setText("\u8bbe\u5907\u7c7b\u522b\uff1a");
jLabel6.setText("\u501f\u7528\u5907\u6ce8\uff1a");
annotationtext.setColumns(20);
annotationtext.setRows(5);
jScrollPane2.setViewportView(annotationtext);
purposetext.setColumns(20);
purposetext.setRows(5);
jScrollPane1.setViewportView(purposetext);
Nametext.setEnabled(false);
sorttext.setEnabled(false);
jLabel7.setText("\u8bbe\u5907\u7f16\u53f7\uff1a");
IDtext.setEditable(false);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(layout.createSequentialGroup()
.add(21, 21, 21)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel3)
.add(jLabel4))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(idtext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.add(nametext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel6)
.add(jLabel5))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jScrollPane2)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 243, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(50, 50, 50)
.add(jButton1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 84, Short.MAX_VALUE)
.add(jButton2)
.add(52, 52, 52))
.add(layout.createSequentialGroup()
.add(21, 21, 21)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(layout.createSequentialGroup()
.add(jLabel2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(Nametext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.add(sorttext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.add(jLabel7)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(IDtext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)))))
.add(21, 21, 21))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(19, 19, 19)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(sorttext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(12, 12, 12)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.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(jLabel7)
.add(IDtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 17, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(idtext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.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.TRAILING)
.add(layout.createSequentialGroup()
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 56, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(jLabel5)
.add(51, 51, 51)
.add(jLabel6)
.add(23, 23, 23)))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2))
.add(18, 18, 18))
);
pack();
}// </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
borrow();
}//GEN-LAST:event_jButton1ActionPerformed
public void settext(){
if(MainFrame.table.getSelectedRow() != -1) {
sorttext.setText(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),2).toString());
Nametext.setText(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),1).toString());
IDtext.setText(MainFrame.rm.getValueAt(MainFrame.table.getSelectedRow(),0).toString());
} else {
JOptionPane.showMessageDialog(this,"请选中你要借用的物品!","错误",JOptionPane.ERROR_MESSAGE);
}
}
public void borrow(){
String sort = sorttext.getText();
String Name = Nametext.getText();
int id=0;
try{
id = Integer.parseInt(idtext.getText());
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "请正确输入您的ID,ID必须为数字!!!", "错误提示", JOptionPane.ERROR_MESSAGE);
idtext.grabFocus();
return;
}
String name = nametext.getText();
String purpose = purposetext.getText();
String annotation = annotationtext.getText();
boolean judgement=false;
String username;
int ID = Integer.parseInt(IDtext.getText());
Calendar sj = Calendar.getInstance();
String s = sj.getTime().toString();
String time = sj.get(Calendar.YEAR)+ "-" + (sj.get(Calendar.MONTH)+1) +
"-" +sj.get(Calendar.DATE) + " " + s.substring(11,s.length()-9);
OpendatabaseClass open = new OpendatabaseClass(sill.getconnection().transmitConnection());
try {
judgement = open.incumbency_attest(id,name);
if(judgement == true){
int i = 0;
username = open.lookup_username();
open.accretion_database(ID,Name,time,id,name,username,purpose,annotation);
i = open.amend_record(ID,Name,name);
if(i>0){
JOptionPane.showMessageDialog(this, "借出成功", "成功提示",
JOptionPane.INFORMATION_MESSAGE);
DatabaseConnection dbc = new DatabaseConnection();
MainFrame.rm.setResult(dbc.getRs());
this.dispose();
}
}else{
JOptionPane.showMessageDialog(this,"没有此Id或此姓名!!!", "失败提示", JOptionPane.ERROR_MESSAGE);
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JTextField IDtext;
public javax.swing.JTextField Nametext;
public javax.swing.JTextArea annotationtext;
public javax.swing.JTextField idtext;
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.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
public javax.swing.JTextField nametext;
public javax.swing.JTextArea purposetext;
public javax.swing.JTextField sorttext;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -