Java汽车售票系统管理

上传人:xuex****hao 文档编号:139296504 上传时间:2022-08-22 格式:DOC 页数:13 大小:258KB
收藏 版权申诉 举报 下载
Java汽车售票系统管理_第1页
第1页 / 共13页
Java汽车售票系统管理_第2页
第2页 / 共13页
Java汽车售票系统管理_第3页
第3页 / 共13页
资源描述:

《Java汽车售票系统管理》由会员分享,可在线阅读,更多相关《Java汽车售票系统管理(13页珍藏版)》请在装配图网上搜索。

1、汽车售票系统设计1 引言对课程设计内容做综述,介绍课程设计的目的和要求等内容,并说明采用什么开发工具设计实现一个什么系统等。实习目的:通过汽车售票系统设计课程设计实习过程,进一步巩固Java程序设计课程所学的理论知识,增强学生利用所学内容获取相关知识,以解决实习过程中所面临的问题友好人机界面的布局设置,数据库的连接,Java访问修改数据库, 实现公路汽车售票系统的设计等功能和连接数据库,利用Java访问数据库,以提高利用Java语言实际动手进行程序设计的能力。上实习要求:能够熟练运用Java,独立设计和编制一个具有一定难度的、解决实际应用问题公路汽车售票系统的设计,包括售票,退票,改签和余票查

2、询等功能2 系统设计(1) 需求分析 公路汽车售票系统的设计,包括售票,退票,改签和余票查询等功能;友好人机界面 (2)总体设计方案 1).系统功能结构图公路汽车售票系统用户登录售票退票改签余票查询2). 各子功能的主要算法流程图 余票查询和售票: 是否有票售票不售票退票:是否有售票票票退票不退票票改签:是否有售票票票改签不改签是否有售票票票退票不退票票数据库的设计:票务数据库:用户消息数据库:3 系统实现登陆界面:public class Login extends JFrame implements ActionListenerprivate JPanel jp =new JPanel()

3、;private JLabel jlArray=new JLabel (用户名),new JLabel (密码),new JLabel ();private JButton jbArray=new JButton (登陆),new JButton (取消);private JTextField jtxt =new JTextField(小明);private JPasswordField jpassword = new JPasswordField(numberl);String sql;public Login()jp.setLayout(null);for(int i =0;i2;i+)j

4、lArrayi.setBounds(30,20+i*50,80,25);jp.add(jlArrayi);for(int i =0;i2;i+)jbArrayi.setBounds(40+i*120,130,100,25);jp.add(jbArrayi);jbArrayi.addActionListener(this);jtxt.setBounds(80,20,180,25);jp.add(jtxt);jtxt.addActionListener(this);jpassword.setBounds(80,70,180,25);jp.add(jpassword);jpassword.setEc

5、hoChar(*);jpassword.addActionListener(this);jlArray2.setBounds(10,280,300,25);jp.add(jlArray2);this.add(jp);Image image= new ImageIcon(ico.gif).getImage();this.setSize(330,220);this.setIconImage(image);this.setTitle(公路汽车售票系统);this.setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSo

6、urce()=jtxt)jpassword.requestFocus();else if(e.getSource()=jbArray1)jlArray1.setText();jtxt.setText();jpassword.setText();jtxt.requestFocus();else if(e.getSource()=jbArray0)sql=select ConName,password from consumer where ConName=+Integer.parseInt(jtxt.getText().trim(); tryString ConName=;String pass

7、word=;jlArray2.setText(恭喜您,登录成功!); new UserSystem(); this.dispose(); catch(Exception e1)e1.printStackTrace();public static void main(String args)new Login();用户公路汽车售票管理界面:public class UserSystem extends JFrame implements ActionListener DefaultMutableTreeNode dmtn= new DefaultMutableTreeNode(new NodeV

8、alue(公路汽车售票系统), new DefaultMutableTreeNode(new NodeValue(售票), new DefaultMutableTreeNode(new NodeValue(退票), new DefaultMutableTreeNode(new NodeValue(改签), new DefaultMutableTreeNode(new NodeValue(余票查询), new DefaultMutableTreeNode(new NodeValue(退出) ; DefaultTreeModel dtm=new DefaultTreeModel(dmtn0); J

9、Tree jt= new JTree (dtm); JScrollPane jsp=new JScrollPane(jt); private JSplitPane jsplr=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true); Image image=new ImageIcon(tsgl.jpg).getImage(); ImageIcon ii =new ImageIcon(image); private JLabel jlRoot=new JLabel(ii); private JPanel jp=new JPanel(); CardLayo

10、ut cl=new CardLayout(); public UserSystem() this.initJp(); jt.addTreeSelectionListener(new TreeSelectionListener() public void valueChanged(TreeSelectionEvent e) DefaultMutableTreeNode cdmtn=(DefaultMutableTreeNode)e.getPath().getLastPathComponent(); NodeValue cnv=(NodeValue)cdmtn.getUserObject(); i

11、f (cnv.value.equals(公路汽车售票系统) cl.show(jp,root); if (cnv.value.equals(售票) cl.show(jp,Buy); else if (cnv.value.equals(退票) cl.show(jp,Return); else if (cnv.value.equals(改签) cl.show(jp,Change); else if (cnv.value.equals(余票查询) cl.show(jp,Ask); else if (cnv.value.equals(退出) int i=JOptionPane.showConfirmDi

12、alog(UserSystem.this,是否退出系统?,消息,JOptionPane.YES_NO_OPTION); if (i=JOptionPane.YES_OPTION)System.exit(0); ); for(int i=1;idmtn.length;i+) dtm.insertNodeInto(dmtni, dmtn0, i-1); jt.setEditable(false); this.add(jsplr); jsplr.setLeftComponent(jt); jp.setBounds(200, 50, 300, 400); jsplr.setRightComponent

13、(jp); jsplr.setDividerLocation(150); jsplr.setDividerSize(4); jlRoot.setFont(new Font(Courier,Font.PLAIN,30); jlRoot.setHorizontalAlignment(JLabel.CENTER); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Image image= new ImageIcon(ico.gif).getImage(); this.setIconImage(image); this.setTitle(公路汽

14、车售票系统); Dimension screenSize= Toolkit.getDefaultToolkit().getScreenSize(); int centerX=screenSize.width/2; int centerY=screenSize.height/2; int w=500; int h=400; this.setBounds(centerX-w/2,centerY-h/2-100,w,h); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setVisible(true); jt.setShowsRootHandl

15、es(true); public void initJp() jp.setLayout(cl); jp.add(jlRoot,root); jp.add(new Buy(),Buy); jp.add(new Return(),Return); jp.add(new Change(),Change); jp.add(new Ask(),Ask); public void actionPerformed(ActionEvent e) public static void main(String args)new UserSystem();class NodeValue/声明NodeValue类St

16、ring value;public NodeValue(String value)this.value=value;public String getValue()/声明NodeValue构造器return this.value;public String toString()return value;售票: public class Buy extends JPanel implements ActionListener private JSplitPane jsp1=new JSplitPane(JSplitPane.VERTICAL_SPLIT,true);private JPanel

17、jp2=new JPanel();int flag;String sql;DataBase db;private JButton jb2=new JButton(确定);private JLabel jl3=new JLabel(请输入要买的车票);private JTextField jtxt3=new JTextField();Vector head = new Vector();/创建标题head.add(票号);head.add(票名);head.add(起点);head.add(终点);head.add(剩余票数);Vector data=new Vector();DefaultTa

18、bleModel dtm=new DefaultTableModel(data,head);JTable jt=new JTable(dtm);JScrollPane jspn=new JScrollPane(jt);public Buy()this.setLayout(new GridLayout(1,1);jsp1.setTopComponent(jp2);jsp1.setBottomComponent(jspn);jsp1.setDividerLocation(80);jsp1.setDividerSize(4);jp2.setLayout(null);jb2.setBounds(400

19、,30,60,20);jp2.add(jb2);jb2.addActionListener(this);jl3.setBounds(60,30,120,20);jp2.add(jl3); jtxt3.setBounds(200,30,100,20); jp2.add(jtxt3); this.add(jsp1); this.setBounds(10,10,800,600); this.setVisible(true); public void actionPerformed(ActionEvent e)if(e.getSource()=jb2)sql=select * from TICKET

20、where TicketNO=+Integer.parseInt(jtxt3.getText().trim(); db=new DataBase();Vector vtemp = new Vector();退票:public class Return extends JPanel implements ActionListener DataBase db;String sql;String str;private JSplitPane jsp=new JSplitPane(JSplitPane.VERTICAL_SPLIT,true);private JPanel jpt=new JPanel

21、();private JPanel jpb=new JPanel();private JButton jbArray=new JButtonnew JButton(退票),new JButton(确定);Vector head = new Vector();head.add(票号);head.add(票名);head.add(起点);head.add(终点);head.add(剩余票数);Vector data=new Vector();DefaultTableModel dtm=new DefaultTableModel(data,head);JTable jt=new JTable(dtm

22、);JScrollPane jspn=new JScrollPane(jt);public Return()this.setLayout(new GridLayout(1,1);jpt.setLayout(null);jpb.setLayout(null); jbArray0.setBounds(20,30,100,20); jbArray1.setBounds(200,30,100,20); for(int i=0;i2;i+) jpt.add(jbArrayi); jbArrayi.addActionListener(this); jsp.setTopComponent(jpt); jsp

23、.setBottomComponent(jspn); jsp.setDividerSize(4); this.add(jsp); jsp.setDividerLocation(80); this.setBounds(10,10,800,600); this.setVisible(true); public void actionPerformed(ActionEvent e)if(e.getSource()=jbArray1)Vector vtemp = new Vector();if(e.getSource()=jbArray0)int row=jt.getSelectedRow();str

24、=(String)jt.getValueAt(row,0);int tno=Integer.parseInt(str);sql=Delete from record where TicketNO=+Integer.parseInt(str); db=new DataBase(); sql=update ticket set RemainTicket=+1 where TicketNO=+Integer.parseInt(str); /updateTable(); public static void main(String args) new Return(); 其他改签和余票查询调用方法差不多在此省略。4 结束语 这个系统的开发我也遇到了很多的困难,一开始对这方面十分的不熟悉,也查阅了很多相关图书,也去网上看了一些相关教学视频,最终终于克服一些困难,建立这个公路汽车售票系统,我深刻体会到开发系统的不容易,我也从中学到了好多知识,我也知道这个系统开发的并不完美,里面也存在一点瑕疵,关于数据库方面也存在诸多问题参考文献:1.Java项目开发案例精粹.曲培新2.尚学堂马士兵JAVA视频教程3.Java程序设计基础第三版.陈国军

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!