📄 dsdialog.java
字号:
package pane_dsdialog;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import pane_query.Pane1;
import stu.Stu;
@SuppressWarnings("serial")
public class Dsdialog extends JDialog implements ActionListener
{
JLabel l1=new JLabel("要删除的记录在查询表中的序号为:");
Object items[]=new Object[(Pane1.N)+1];
JComboBox cb;
JFrame f;
JButton bs=new JButton("删除");
JButton bt=new JButton("退出");
JPanel p1=new JPanel();
JPanel p11=new JPanel();
JPanel p12=new JPanel();
JPanel p2=new JPanel();
JPanel p21=new JPanel();
JPanel p22=new JPanel();
JButton bs2=new JButton("继续");
JButton bt2=new JButton("退出");
JLabel l2=new JLabel("已经清楚数据库中该记录。");
CardLayout car=new CardLayout();
Container con=getContentPane();
public Dsdialog (JFrame F,String s)
{
super(F,s,true);
for(int i=1;i<=Pane1.N;i++)
{
items[i]=i;
}
items[0]="所有";
setSize(400,115);
setLocation(300,250);
con.setLayout(car);
cb=new JComboBox(items);
p1.setLayout(new GridLayout(2,1));
p11.add(l1);
p11.add(cb);
p1.add(p11);
bs.addActionListener(this);
bt.addActionListener(this);
bs2.addActionListener(this);
bt2.addActionListener(this);
p12.add(bs);
p12.add(bt);
p1.add(p12);
con.add("1",p1);
p2.setLayout(new GridLayout(2,1));
p21.add(l2);
p22.add(bs2);
p22.add(bt2);
p2.add(p21);
p2.add(p22);
con.add("2",p2);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==bs)
{
String temp4;
try
{
int n=cb.getSelectedIndex();
if(n>0)
{
temp4="delete from 学生管理系统.dbo.学生基本信息 where Num='"+Pane1.a[n-1][3]+"'";
Stu.pstmt = Stu.conn.prepareStatement(temp4);
Stu.pstmt.executeUpdate();
// Stu.conn.close();
}
else
{
for(int i=0;i<Pane1.N;i++)
{
temp4="delete from 学生管理系统.dbo.学生基本信息 where Num='"+Pane1.a[i][3]+"'";
Stu.pstmt = Stu.conn.prepareStatement(temp4);
Stu.pstmt.executeUpdate();
//Stu.conn.close();
}
car.show(con,"2");
}
}catch(SQLException ee)
{
//System.out.println(ee.toString());
}
}
if(e.getSource()==bt)
{
this.dispose();
}
if(e.getSource()==bs2)
{
car.show(con, "1");
}
if(e.getSource()==bt2)
{
this.dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -