📄 shujian.java
字号:
package infomanagement;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2003</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Font;
import com.borland.jbcl.layout.XYLayout;
import java.awt.Color;
import com.borland.dx.dataset.Column;
import javax.swing.JDialog;
import javax.swing.JTextField;
import java.awt.Frame;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import javax.swing.JLabel;
import com.borland.jbcl.layout.XYConstraints;
import javax.swing.JButton;
import java.awt.event.MouseEvent;
import java.awt.Dimension;
import java.awt.Point;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2003</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class shujian extends JDialog {
private JPanel jPanel1 = new JPanel();
private XYLayout xYLayout1 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JLabel jLabel4 = new JLabel();
private QueryDataSet queryDataSet1 = new QueryDataSet();
private Database database1 = new Database();
private QueryDataSet queryDataSet2 = new QueryDataSet();
private Column column1 = new Column();
JLabel jLabel5 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
JLabel jLabel2 = new JLabel();
public shujian(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public shujian() {
this(null, "", false);
}
private void jbInit() throws Exception {
jPanel1.setLayout(xYLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 23));
jLabel1.setForeground(Color.magenta);
jLabel1.setBorder(BorderFactory.createEtchedBorder());
jLabel1.setText(" 图书删除窗口");
jLabel4.setBorder(BorderFactory.createEtchedBorder());
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor
("jdbc:odbc:local", "sa", "", false,
"sun.jdbc.odbc.JdbcOdbcDriver"));
column1.setColumnName("NewColumn1");
column1.setDataType(com.borland.dx.dataset.Variant.STRING);
column1.setPreferredOrdinal(0);
column1.setServerColumnName("NewColumn1");
column1.setSqlType(0);
jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel5.setForeground(Color.magenta);
jLabel5.setText("书号");
jButton1.setText("删除");
jButton1.addMouseListener(new java.awt.event.MouseAdapter()
{
//判断输入是否正确,是就进入,否就弹出一个对话框提示错误
public void mouseClicked(MouseEvent e)
{
abClicked(e);
}
}
);
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel2.setForeground(Color.red);
jLabel2.setText("请输入要删除图书的书号");
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jLabel1, new XYConstraints(0, 1, 399, 53));
jPanel1.add(jButton1, new XYConstraints(165, 231, -1, -1));
jPanel1.add(jLabel2, new XYConstraints(92, 67, -1, -1));
jPanel1.add(jTextField2, new XYConstraints(189, 147, 90, -1));
jPanel1.add(jLabel5, new XYConstraints(114, 144, -1, -1));
jPanel1.add(jLabel4, new XYConstraints(1, 99, 397, 202));
}
void abClicked(MouseEvent e)
{
String a=jTextField2.getText();
String query="delete from book where 书号="+"'"+a+"'";
try
{
dabaco bb=new dabaco();
Statement ps=bb.conn.createStatement();
String gg;
boolean mk=false;
String query1="select 书号 from book";
ResultSet ff=bb.stmt.executeQuery(query1);
while(ff.next())
{
gg=ff.getString(1);
if(mk==true)
{
}
else if(gg.equals(a))
{
mk=true;
//System.out.println("aaaaaa");
}
else
{
}
}
if(mk==true)
{
//System.out.println("aaaaaa");
ResultSet rs = ps.executeQuery(query);
//System.out.println("adffiefiefjeif");
//ResultSet rs=ps.executeQuery();
}
else
{
my dlg = new my();
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation( (frmSize.width - dlgSize.width) / 2 +
loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
dlg.pack();
dlg.setVisible(true);
//ResultSet rs = bb.stmt.executeUpdate(query);
}}
catch(SQLException ex)
{
}
}
void cancel(){
dispose() ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -