景点售票系统源代码.docx
- 文档编号:29906735
- 上传时间:2023-08-03
- 格式:DOCX
- 页数:41
- 大小:22.35KB
景点售票系统源代码.docx
《景点售票系统源代码.docx》由会员分享,可在线阅读,更多相关《景点售票系统源代码.docx(41页珍藏版)》请在冰豆网上搜索。
景点售票系统源代码
importjava.awt.Dimension;
importjava.awt.GridLayout;
importjava.awt.Toolkit;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JPasswordField;
importjavax.swing.JTextField;
publicclassLogOn
{
publicstaticvoidmain(String[]args)throwsSQLException
{
finalJFramejfrmlogin=newJFrame("系统登录");
jfrmlogin.setSize(400,280);
DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();
jfrmlogin.setLocation((int)(screenSize.width-400)/2,(int)(screenSize.height-300)/2);//设置框出现的位置
JPanelp1=newJPanel();
p1.add(newJLabel("用户名:
"));
finalJTextFieldjtxtuser=newJTextField(14);
JPanelp2=newJPanel();
p2.add(newJLabel("密码:
"));
finalJPasswordFieldjspwd=newJPasswordField(14);
JPanelp3=newJPanel();
finalJButtonjbtUser=newJButton("登录");
finalJButtonjbtreg=newJButton("注册");
JButtonjbtexit=newJButton("退出");
p1.add(jtxtuser);
p2.add(jspwd);
p3.add(jbtUser);
p3.add(jbtreg);
p3.add(jbtexit);
jbtUser.addActionListener(newActionListener()
{
publicvoidactionPerformed(ActionEvente)
{
Connectionconn=null;
ResultSetrs=null;
Statementstmt=null;
if(e.getSource()==jbtUser)
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:
oracle:
thin:
@localhost:
1521:
orcl","system","123");
stmt=conn.createStatement();
StringUSER_NAME=jtxtuser.getText();
rs=stmt.executeQuery("select*fromTICKET_USERSwhereUSER_NAME='"+jtxtuser.getText()+"'andUSER_PWD='"+jspwd.getText()+"'");
if(rs.next())
{
if(USER_NAME.equals("admin")==false)
{
MainUsermf=newMainUser();
mf.setVisible(true);
jfrmlogin.dispose();
}
else
{
MainFramemf=newMainFrame();
mf.setVisible(true);
jfrmlogin.dispose();
}
}
else{
JOptionPane.showMessageDialog(null,"用户名或密码不一致,请重新输入!
","系统提示",JOptionPane.ERROR_MESSAGE);
jtxtuser.setText("");
jspwd.setText("");
}
}catch(Exceptionex){
JOptionPane.showMessageDialog(null,"用户名或密码不一致,请重新输入!
","系统提示",JOptionPane.ERROR_MESSAGE);
jtxtuser.setText("");
jspwd.setText("");
}
}
}
});
jbtreg.addActionListener(newActionListener()
{
publicvoidactionPerformed(ActionEvente)
{
Connectionconn=null;
ResultSetrs=null;
Statementstmt=null;
if(e.getSource()==jbtreg)
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:
oracle:
thin:
@localhost:
1521:
orcl","system","123");
stmt=conn.createStatement();
rs=stmt.executeQuery("insertintoTICKET_USERS(USER_NAME,USER_PWD)values('"+jtxtuser.getText()+"','"+jspwd.getText()+"')");
if(rs.next())
{
JOptionPane.showMessageDialog(null,"你已成功注册!
可以登录了!
","系统提示",JOptionPane.INFORMATION_MESSAGE);
jtxtuser.setText("");
jspwd.setText("");
}
else{
JOptionPane.showMessageDialog(null,"用户注册失败!
","系统提示",JOptionPane.ERROR_MESSAGE);
jtxtuser.setText("");
jspwd.setText("");
}
}catch(Exceptionex){
JOptionPane.showMessageDialog(null,"用户注册失败!
","系统提示",JOptionPane.ERROR_MESSAGE);
jtxtuser.setText("");
jspwd.setText("");
}
}
}
});
jbtexit.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
System.exit(0);
}
});
jfrmlogin.getContentPane().setLayout(newGridLayout(3,1));
jfrmlogin.getContentPane().add(p1);
jfrmlogin.getContentPane().add(p2);
jfrmlogin.getContentPane().add(p3);
jfrmlogin.setVisible(true);
}
}
importjava.sql.*;
publicclassConnectOracle{
publicstaticvoidconnection(String[]args)throwsSQLException{
//Connectionconn=null;
//Statementstmt=null;
//ResultSetrs=null;
//JDBC直连Oracle数据库加载驱动
try{
System.out.println("正在连接数据库.......");
Class.forName("oracle.jdbc.driver.OracleDriver");
/*conn=*/DriverManager.getConnection("jdbc:
oracle:
thin:
@localhost:
1521:
orcl","system","123");
System.out.println("已经连接到数据库.....");
//stmt=conn.createStatement();
//stmt.executeQuery("insertintostudent(STUID,STUNAME,SEX,AGE)values(0001,'李华','男',20)");
//rs=stmt.executeQuery("select*fromSTUDENT");
//System.out.println("stuID"+"StuName"+"Sex"+"Age");
//while(rs.next()){
//intSTUID=rs.getInt("STUID");
//StringSTUNAME=rs.getString("STUNAME");
//StringSEX=rs.getString("SEX");
//intAGE=rs.getInt("AGE");
//System.out.println(""+STUID+""+STUNAME+""+SEX+""+AGE);
//System.out.println("STUID"+STUID+"STUNAME"+STUNAME+"SEX"+SEX+"AGE"+AGE);
//}
}catch(Exceptionex){
//System.out.println("出现的异常为"+ex);;
}
}
}
importjava.awt.Rectangle;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.Statement;
importjavax.swing.JButton;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JTextField;
publicclassAddTicketextendsJPanelimplementsActionListener
{
Connectioncon;
Statementst;
JLabeljLabel1=newJLabel("票单价:
");
JLabeljLabel2=newJLabel("票日期:
");
JTextFieldjTextField1=newJTextField();
JTextFieldjTextField2=newJTextField();
JButtonjButton1=newJButton("确定增加");
publicAddTicket()
{
try{
jbInit();
}
catch(Exceptionexception){
exception.printStackTrace();
}
}
privatevoidjbInit()throwsException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:
oracle:
thin:
@localhost:
1521:
orcl","system","123");
this.setLayout(null);
jLabel1.setBounds(newRectangle(40,40,64,24));
jLabel2.setBounds(newRectangle(40,100,53,22));
jTextField1.setBounds(newRectangle(102,40,200,30));
jTextField2.setBounds(newRectangle(102,100,200,30));
jButton1.setBounds(newRectangle(120,220,150,32));
jButton1.addActionListener(this);
this.add(jLabel1);
this.add(jTextField1);
this.add(jLabel2);
this.add(jTextField2);
this.add(jButton1);
ResultSetrs=null;
st=con.createStatement();
rs=st.executeQuery("select*fromTICKET_TRANSCRIPT");
if(rs.next())
{
jTextField1.setText(rs.getString("TICKET_PRICE"));
}
}
publicvoidactionPerformed(ActionEvente)
{
try{
st=con.createStatement();
st.executeUpdate("deletefromTICKET");
st.executeUpdate("deletefromTICKET_ORDER_FORM");
st.executeUpdate("insertintoTICKETselect*fromTICKET_TRANSCRIPT");
st.executeUpdate("updateTICKETsetTICKET_DATE='"+jTextField2.getText()+"'");
st.executeUpdate("updateTICKETsetTICKET_PRICE='"+jTextField1.getText()+"'");
JOptionPane.showMessageDialog(this,"票增加成功!
");
jTextField1.setText("");
jTextField2.setText("");
}
catch(Exceptionex){
JOptionPane.showMessageDialog(this,"票增加失败!
");
ex.printStackTrace();
}
}
}
importjavax.swing.*;
importjavax.swing.table.JTableHeader;
importjava.awt.Rectangle;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.*;
publicclassAdminInquireTicketextendsJFrame
{
Connectioncon;
Statementst;
privateJScrollPanescpDemo;
privateJTableHeaderjth;
privateJTabletabDemo;
privateJButtonbtnShow;
privateJButtonbtnShow1;
publicAdminInquireTicket()
{
super("华清池售票系统");
this.setSize(430,400);
this.setLayout(null);
this.setLocation(500,180);
this.scpDemo=newJScrollPane();
this.scpDemo.setBounds(10,50,390,270);
this.btnShow=newJButton("显示票信息");
this.btnShow.setBounds(10,10,390,30);
this.btnShow1=newJButton("返回");
this.btnShow1.setBounds(260,330,120,30);
JLabeljLabel1=newJLabel("余票总数:
");
JTextFieldjTextField1=newJTextField();
jLabel1.setBounds(newRectangle(20,330,100,30));
jTextField1.setBounds(newRectangle(90,330,70,30));
add(this.scpDemo);
add(this.btnShow);
add(this.btnShow1);
this.add(jLabel1);
this.add(jTextField1);
this.setVisible(true);
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:
oracle:
thin:
@localhost:
1521:
orcl","system","123");
ResultSetrs=null;
intn=0;
st=con.createStatement();
rs=st.executeQuery("select*fromTICKET");
while(rs.next())
{
n++;
}
jTextField1.setText(""+n+"");
}catch(Exceptionexception){
exception.printStackTrace();
}
this.btnShow1.addActionListener(newActionListener()
{
publicvoidactionPerformed(ActionEvente)
{
MainFramemu=newMainFrame();
mu.setVisible(true);
dispose();
}
});
this.btnShow.addActionListener(newActionListener()
{
publicvoidactionPerformed(ActionEventae)
{
btnShow_ActionPerformed(ae);
}
});
}
publicvoidbtnShow_ActionPerformed(ActionEventae)
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connectioncon=DriverManager.getConnection("jdbc:
oracle:
thin:
@localhost:
1521:
orcl","system","123");
Stringsql="select*fromTICKET";
PreparedStatementpstm=con.prepareStatement(sql);
ResultSetrs=pstm.executeQuery();
intcount=0;
while(rs.next())
{
count++;
}
rs=pstm.executeQuery();
Object[][]info=newObject[count][4];
count=0;
while(rs.next())
{
info[count][0]=rs.getString("TICKET_NUM");
info[count][1]=rs.getString("TICKET_DATE");
info[count][2]=rs.getString("TICKET_PR
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 景点 售票 系统 源代码