删除学生信息_第1页
删除学生信息_第2页
删除学生信息_第3页
删除学生信息_第4页
删除学生信息_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

import javax swing import java awt import java awt event import java sql public class deleteForm extends JFrame implements ActionListener JPanel jpl new JPanel JLabel SCH new JLabel 删除学生信息 JLabel CENTER Font f new Font 楷体 Font BOLD Font ITALIC 30 JLabel label1 new JLabel 请输入学号 JLabel CENTER JButton btnQuery new JButton 查询 JLabel label2 new JLabel 姓名 JLabel CENTER JLabel labyear new JLabel 年龄 JLabel CENTER JLabel labDate new JLabel 出生日期 JLabel CENTER JLabel label5 new JLabel 性别 JLabel CENTER JLabel label3 new JLabel 班级 JLabel CENTER JLabel label4 new JLabel 专业 JLabel CENTER JLabel labmz new JLabel 民族 JLabel CENTER ButtonGroup bgp new ButtonGroup JRadioButton man new JRadioButton 男 JRadioButton women new JRadioButton 女 JTextField tyear new JTextField JTextField tDate new JTextField JTextField tmz new JTextField JTextField num new JTextField JTextField nam new JTextField JTextField clas new JTextField JTextField scl new JTextField JButton btnDelete new JButton 删除 JButton btnCancel new JButton 取消 Connection con Statement sql ResultSet rs int re deleteForm this setSize 560 460 this setVisible true this setResizable false SCH setForeground Color BLACK this setDefaultCloseOperation JFrame EXIT ON CLOSE this add jpl jpl setBackground Color LIGHT GRAY man setBackground Color LIGHT GRAY women setBackground Color LIGHT GRAY jpl setLayout null btnQuery addActionListener this btnDelete addActionListener this btnCancel addActionListener this SCH setBounds 100 20 300 20 jpl add SCH label1 setBounds 100 60 100 20 jpl add label1 num setBounds 220 60 140 20 jpl add num btnQuery setBounds 120 100 90 20 btnDelete setBounds 230 100 90 20 btnCancel setBounds 340 100 90 20 jpl add btnQuery jpl add btnDelete jpl add btnCancel label2 setBounds 100 150 70 20 jpl add label2 nam setBounds 190 150 140 20 jpl add nam labyear setBounds 100 180 70 20 jpl add labyear tyear setBounds 190 180 140 20 jpl add tyear labDate setBounds 100 210 70 20 jpl add labDate tDate setBounds 190 210 140 20 jpl add tDate label5 setBounds 100 250 70 20 jpl add label5 man setBounds 205 250 60 20 women setBounds 285 250 60 20 bgp add man bgp add women jpl add man jpl add women label3 setBounds 100 290 70 20 jpl add label3 clas setBounds 190 290 140 20 jpl add clas label4 setBounds 100 320 70 20 jpl add label4 scl setBounds 190 320 140 20 jpl add scl labmz setBounds 100 350 70 20 jpl add labmz tmz setBounds 190 350 140 20 jpl add tmz btnDelete setEnabled false 取消删除按钮的功能 nam setEditable false tyear setEditable false tDate setEditable false clas setEditable false scl setEditable false tmz setEditable false setVisible true num requestFocus public void actionPerformed ActionEvent ae if ae getSource btnCancel dispose new mainFrame setVisible true else if ae getSource btnQuery try Class forName sun jdbc odbc JdbcOdbcDriver catch ClassNotFoundException e try con DriverManager getConnection jdbc odbc local root 123456 sql con createStatement rs sql executeQuery select from Information where ID num getText if rs next num setText rs getString ID nam setText rs getString Name tyear setText rs getString Age toString tDate setText rs getString Birthday if rs getString Sex equals 男 man setSelected true else women setSelected true clas setText rs getString Class scl setText rs getString Major tmz setText rs getString Nation btnDelete setEnabled true nam setEditable true tyear setEditable true tDate setEditable true clas setEditable true scl setEditable true tmz setEditable true else JOptionPane showMessageDialog null 不存在该记录 温馨 提示 JOptionPane INFORMATION MESSAGE btnDelete setEnabled false tyear setText tDate setText tmz setText num setText nam setText clas setText scl setText num requestFocus nam setEditable false tyear setEditable false tDate setEditable false clas setEditable false scl setEditable false tmz setEditable false catch SQLException e else if ae getSource btnDelete 实现删除功能 try con DriverManager getConnection jdbc odbc local root 123456 sql con createStatement re sql executeUpdate DELETE FROM Information where ID num getText if re 1 JOptionPane showMessageDialog null 记录删除完毕 温馨 提示 JOptionPane INFORMATION MESSAGE else JOptionPane showMessageDialog null 记录删除失败 温馨 提示 JOptionPane INFORMATION MESSAGE sql close catch SQLException se JOptionPane showMessageDialog null se getMessage else btnDelete setEnabled false tyear setText tDate setText tmz setText num setText nam setText clas s

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论