資源簡介
采用JAVA編寫的數據庫課程設計,數據庫用的是sqlserver 2000 ,只能傳源碼,只做大家參考吧

代碼片段和文件信息
/**
?*?@(#)AddRecord1.java
?*
?*
?*?@author?
?*?@version?1.00?2011/2/24
?*/
package?wuwenzhe;
import?java.io.*;
import?javax.swing.*;
import?java.awt.event.*;
import?java.awt.*;
import?wuwenzhe.Database1;
import?wuwenzhe.RecordItem1;
public?class?AddRecord1?extends?Jframe{
Database1?db1=new?Database1();
JTextField?t1=new?JTextField();
JTextField?t2=new?JTextField();
JTextField?t3=new?JTextField();
JTextField?t4=new?JTextField();
JTextField?t5=new?JTextField();
JLabel?label1=?new?JLabel(“流水號“);
JLabel?label2=?new?JLabel(“姓名“);
JLabel?label3=?new?JLabel(“性別“);
JLabel?label4=?new?JLabel(“年齡“);
JLabel?label5=?new?JLabel(“科室號“);
JButton?add=new?JButton(“添加“);
JButton?quit=new?JButton(“放棄“);
JButton?reset=new?JButton(“重置“);
Container?con;
JPanel?p1=new?JPanel();
JPanel?p2=new?JPanel();
????public?AddRecord1()?{
???? settitle(““);
???? con=getContentPane();
???? con.setLayout(new?BorderLayout());
???? con.add(p1BorderLayout.CENTER);
???? con.add(p2BorderLayout.SOUTH);
???? p1.setLayout(new?GridLayout(52));
???? p1.add(label1);
???? p1.add(t1);
???? p1.add(label2);
???? p1.add(t2);
???? p1.add(label3);
???? p1.add(t3);
???? p1.add(label4);
???? p1.add(t4);
???? p1.add(label5);
???? p1.add(t5);
????
???? p2.setLayout(new?FlowLayout());
???? p2.add(add);
???? p2.add(quit);
???? p2.add(reset);
????
???? add.addActionListener(new?ActionListener()
???? {
???? public?void?actionPerformed(ActionEvent?e)
???? {
???? AddRecord();
???? }
???? });
????
???? quit.addActionListener(new?ActionListener()
???? {
???? public?void?actionPerformed(ActionEvent?e)
???? {
???? dispose();
???? }
???? });
????
???? reset.addActionListener(new?ActionListener?()
???? {
???? public?void?actionPerformed(ActionEvent?e)
???? {
???? ResetRecord();
???? }
???? });
???? addWindowListener(new?WindowAdapter()
???? {
???? public?void?windowClosing(WindowEvent?e)
???? {
???? dispose();
???? }
???? });
????
????
????
????
????}
????
????public?void?AddRecord()
????{
???? String[]?str={““““““““““};
????
????
????
???? str[0]=t1.getText();
???? str[1]=t2.getText();
???? str[2]=t3.getText();
???? str[3]=t4.getText();
???? str[4]=t5.getText();
???? int?i;
???? for(i=0;i<5;i++)
???? {
???? if(str[i].trim().length()==0)
???? { System.out.println(str[i]);
???? break;
???? }
???? }
????
???? if(i<5)
???? JOptionPane.showMessageDialog(this“以上信息為必填信息不能偷懶!“);
???? else
???? {
???? RecordItem1?record=new?RecordItem1();
???? record.SetFlowNumber(str[0]);
???? record.SetName(str[1]);
???? record.SetSex(str[2]);
????
???? record.SetAge(Integer.valueOf(str[3]));
????
???? record.SetDepartment(str[4]);
???? try
???? {
???? if(db1.StoreData(record)==0)
???? {
???? JOptionPane.showMessageDialog(this“流水號重復,無法插入記錄“);
???? return;
???? }
????
???? }
???? catch(Exception?e)
???? {
????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-03-03?19:51??bin\
?????目錄???????????0??2011-03-03?19:51??src\
?????文件?????????232??2011-03-02?14:37??src\.classpath
?????文件?????????379??2011-03-02?14:37??src\.project
?????文件????????3365??2011-02-24?14:34??src\AddRecord1.java
?????文件?????????570??2011-02-23?21:00??src\Databa
?????文件????????2257??2011-03-02?15:32??src\Databa
?????文件????????1016??2011-02-23?19:20??src\RecordItem1.java
?????文件????????1912??2011-02-24?15:03??src\Register.java
?????文件????????2203??2011-02-24?12:28??src\TablePanel.java
- 上一篇:基于JSP實現的在線投票系統
- 下一篇:使用poi操作PPT
評論
共有 條評論