软件项目开发总结报告模版.doc_第1页
软件项目开发总结报告模版.doc_第2页
软件项目开发总结报告模版.doc_第3页
软件项目开发总结报告模版.doc_第4页
软件项目开发总结报告模版.doc_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

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

文档简介

武汉理工大学软件开发工具论文报告火车票系统的开发1引言随着人们生活水平和经济水平的提高,网络科技的全球化的发展,出游和出差的频率越来越多。这大大的激发了交通水平的发展。其中,火车这种又方便有便宜的交通工具作为人们的首选,火车站的客运列车增加,客运量也随之增加。原有的售票的方式已经不再能满足旅客的需求了。为了方便旅客售票系统不仅仅只能售票也能够了解列车的各种信息。这样才能成为现在网络社会的真的适应者。2需求分析该售票系统是融合了火车票销售、退票、列车管理、车票管理、售票员管理、列车管理信息,以及售票信息查询为一体的综合系统。该系统主要编写的功能是列车和售票信息的查询及售票功能。2.1用户该系统主要有两类用户:管理员和售票员。管理员主要工作有车次管理,车票管理和售票员管理。对于每项功能都有添加,删除和修改的功能。售票的主要工作是售票和退票。2.2主要功能该系统从功能方面可以分为四个方面:登录。不管你是管理员还是售票员必须登录以后才可以进行系统允许的操作。当然要登录的管理员和售票员都必须是再数据库中已经发布的。基本设置:该模块主要是修改售票员的相关信息,修改列车的相关信息和修改车票的相关信息。这一块的功能只有管理员才可以操作。其他的售票员是不可以对他进行操作的。售票和退票:这部分工作主要是售票员来操作的。售票员根据买票人员提出的要求进行查询。查询的方式有两种:一是根据车次查询;一是根据目的地来查询。退票主要是将已经出售的车票在列车开出之前再一次的返回到数据库中,并继续出售。列车和车票查询;当需要查询列车信息或者是车票信息是所做的操作。2.3基本流程3开发过程3.1内容 该程序包括三个部分数据库的设计、通用模块的实现、各个模块的实现。 3.1.1 数据库的设计: 将本系统所需的所有的数据都存储到数据库中。需要在数据库中管理员表、 售票员表、列车信息表和车票信息表。如图所示:管理员表:售票员表:列车信息表:车票信息表:3.1.2通用模块的实现:通用模块为了减少代码的重复。在该系统中,对经常使用的操作进行封装,如将多次需要调用的数据库和操作数库的增、删、改和查等操作进行封装。使代码有很好的重用性,即使出现错误也很容易调试。如本程序中的Conn.javaimport java.sql.*;public class Conn private static Connection con;private static final String DRIVER = com.mysql.jdbc.Driver;private static final String URL =jdbc:mysql:/localhost:3306/newdatabase;private static final String NAME=root;private static final String PASSWORD=021702190804;statictry Class.forName(DRIVER); catch (ClassNotFoundException e) e.printStackTrace();public static Connection getConnection()try con=DriverManager.getConnection(URL,NAME,PASSWORD); catch (SQLException e) e.printStackTrace();return con;public static void closeCon(Connection con)try if(con!=null)con.close(); catch (SQLException e) e.printStackTrace();public static void closePt(PreparedStatement pt)try if(pt!=null)pt.close(); catch (Exception e) e.printStackTrace();public static void closeRs(ResultSet rs)try if(rs!=null)rs.close(); catch (Exception e) e.printStackTrace();用户登录界面的设计、主界面的设计、基本设置模块、销售及退票模块和列车及车票查询模块。 用户登录模块:该部分是通过设计login.java来实现的。这部分代码的作用是用户首先选择自己的登录的是管理员还是售票员,然后输入账号和密码。单击登录,用户先判断用户登录的类型,然后给sql变量赋SQL语句值,系统调用DAO.java类的login()传入sql变量。.Login 代码是:import org.eclipse.swt.SWT;import org.eclipse.swt.events.*;import org.eclipse.swt.graphics.Image;import org.eclipse.swt.layout.*;import org.eclipse.swt.widgets.*;import com.huizhi.dao.DAO;public class Login private Text nameText; private Text passText; private Combo combo; private String type; private Display display = new Display(); private Shell shell = new Shell(display); public Login() FormLayout layout = new FormLayout(); layout.marginHeight =40; layout.marginWidth =40; shell.setLayout(layout); shell.setText(login); Image image = new Image(display,2.jpg); shell.setBackgroundImage(image); setUIControl(); shell.pack(); shell.open(); while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep(); display.dispose(); private void setUIControl() Label username = new Label(shell, SWT.NONE); username.setText(username); nameText = new Text(shell, SWT.SINGLE | SWT.BORDER); Label password = new Label(shell, SWT.NONE); password.setText(password); passText = new Text(shell, SWT.SINGLE | SWT.BORDER| SWT.PASSWORD); / passText.setEchoChar(*); Label select=new Label(shell, SWT.NONE); select.setText( select ); Button submit = new Button(shell,SWT.PUSH); submit.setText(login ); submit.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)type=combo.getText();String name=nameText.getText();String pass=passText.getText();String sql=null;boolean flag=false;MessageBox box=new MessageBox(shell,SWT.OK);if(.equals(type)|.equals(name)|.equals(pass)box.setMessage(please input all the information);box.open();return ;DAO dao=new DAO();if(users.equals(type)sql=select * from users where username=+name+ and password=+pass+;else if(admin.equals(type)sql=select * from admin where username=+name+ and password=+pass+;flag=dao.login(sql);if(flag)shell.dispose();new Main(type);elsebox.setMessage(wrong name or password);box.open();); Button reset = new Button(shell, SWT.PUSH); reset.setText(cancel); String value=users,admin; combo=new Combo(shell,SWT.DROP_DOWN); combo.setItems(value); FormData data = new FormData(); data.top = new FormAttachment(30,0); username.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(username,0,SWT.CENTER); data.left = new FormAttachment(username,10, SWT.RIGHT); nameText.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(select,0,SWT.CENTER); data.left = new FormAttachment(select,10, SWT.RIGHT); combo.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(username,10, SWT.BOTTOM); password.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(password,0,SWT.CENTER); data.left = new FormAttachment(nameText,0,SWT.LEFT); passText.setLayoutData(data); data=new FormData(); data.top=new FormAttachment(password,10,SWT.BOTTOM); submit.setLayoutData(data); data=new FormData(); data.top=new FormAttachment(submit,0,SWT.CENTER); data.left=new FormAttachment(submit,20,SWT.RIGHT); reset.setLayoutData(data); public static void main(String args) new Login(); DAO.java的login()代码:public boolean login(String sql)boolean flag=false;con=Conn.getConnection();try pt=con.prepareStatement(sql);rs=pt.executeQuery();if(rs.next()flag=true; catch (SQLException e) e.printStackTrace();finallyConn.closeRs(rs);Conn.closePt(pt);Conn.closeCon(con);return flag;图示为;实现主界面:import org.eclipse.swt.*;import org.eclipse.swt.widgets.*;import org.eclipse.swt.layout.*;import org.eclipse.swt.events.*;public class Main private String type;Display display=Display.getCurrent();Shell shell=new Shell(display);public Main(String type)this.type=type;shell.setText(Train ticketing system);shell.setLayout(new FillLayout(); Menu menu=new Menu(shell,SWT.BAR); /第一个菜单MenuItem basic=new MenuItem(menu,SWT.CASCADE);basic.setText(Basic Settings);if(users.equals(type)basic.setEnabled(false);Menu filemenu=new Menu(shell,SWT.DROP_DOWN);MenuItem train=new MenuItem(filemenu,SWT.PUSH);train.setText(Trains Management);train.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new TrainManage(););MenuItem ticket=new MenuItem(filemenu,SWT.PUSH);ticket.setText(Tickets Management);ticket.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new TicketManage(););MenuItem users=new MenuItem(filemenu,SWT.PUSH);users.setText(Users Management);users.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new UsersManage(););MenuItem exit=new MenuItem(filemenu,SWT.PUSH);exit.setText(quit);basic.setMenu(filemenu);exit.addSelectionListener(new SelectionAdapter() public void widgetSelected(SelectionEvent e)display.dispose(););/第二个菜单MenuItem market=new MenuItem(menu,SWT.CASCADE);market.setText(Sales and Refunds);Menu editMenu=new Menu(shell,SWT.DROP_DOWN);MenuItem marketItem=new MenuItem(editMenu,SWT.PUSH);marketItem.setText(Sales Tickets);marketItem.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new XiaosTicket(););MenuItem refundItem=new MenuItem(editMenu,SWT.PUSH);refundItem.setText(Refunds Tickets);market.setMenu(editMenu);refundItem.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new TuiTicket(););/第三个菜单MenuItem find=new MenuItem(menu,SWT.CASCADE);find.setText(Trains and Tickets query);Menu taiMenu=new Menu(shell,SWT.DROP_DOWN);MenuItem trainFind=new MenuItem(taiMenu,SWT.PUSH);trainFind.setText(Trains query);trainFind.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new FindTrain(););MenuItem ticketFind=new MenuItem(taiMenu,SWT.PUSH);ticketFind.setText(Ticket query);find.setMenu(taiMenu);ticketFind.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new FindTicket(););shell.setMenuBar(menu);shell.setSize(500,400);shell.open(); while(!shell.isDisposed() if(!display.readAndDispatch() display.sleep(); display.dispose(); 图示为:基本设置模块包括车次管理,车票管理和售票员管理。车次管理主要是是对于列车的增加,删除和修改等操作。其中包括它的相关的信息等。它是由TrainManagement.java.代码如下:import java.util.List;import org.eclipse.swt.SWT;import org.eclipse.swt.events.*;import org.eclipse.swt.layout.*;import org.eclipse.swt.widgets.*;import com.huizhi.dao.DAO;import com.huizhi.vo.Train;public class TrainManage Display display=Display.getCurrent();Shell tmshell=new Shell(display);final Table table=new Table(tmshell,SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER|SWT.FULL_SELECTION);TrainManage tm=this;public TrainManage()RowLayout rowLayout=new RowLayout();rowLayout.pack=true;rowLayout.wrap=true;rowLayout.justify=false;rowLayout.marginTop=20;tmshell.setLayout(rowLayout);final TableColumn column1=new TableColumn(table,SWT.LEFT);column1.setText(Train ID);column1.setWidth(80);final TableColumn column2=new TableColumn(table,SWT.LEFT);column2.setText(TrainNum);column2.setWidth(80);final TableColumn column3=new TableColumn(table,SWT.LEFT);column3.setText(TrainType);column3.setWidth(80);final TableColumn column4=new TableColumn(table,SWT.LEFT);column4.setText(Starting);column4.setWidth(80);final TableColumn column5=new TableColumn(table,SWT.LEFT);column5.setText(startingTime);column5.setWidth(80);final TableColumn column6=new TableColumn(table,SWT.LEFT);column6.setText(terminal);column6.setWidth(80);final TableColumn column7=new TableColumn(table,SWT.LEFT);column7.setText(terminal Time);column7.setWidth(80);final TableColumn column8=new TableColumn(table,SWT.LEFT);column8.setText(is kongtiao);column8.setWidth(80);final TableColumn column9=new TableColumn(table,SWT.LEFT);column9.setText(price);column9.setWidth(80);final TableColumn column10=new TableColumn(table,SWT.LEFT);column10.setText(middleStation);column10.setWidth(80);final TableColumn column11=new TableColumn(table,SWT.LEFT);column11.setText(yzNum);column11.setWidth(80);final TableColumn column12=new TableColumn(table,SWT.LEFT);column12.setText(rzNum);column12.setWidth(80);final TableColumn column13=new TableColumn(table,SWT.LEFT);column13.setText(ywNum);column13.setWidth(80);final TableColumn column14=new TableColumn(table,SWT.LEFT);column14.setText(rwNum);column14.setWidth(80);table.setHeaderVisible(true);table.setLinesVisible(true);freshData();table.setSize(800,200);Button add=new Button(tmshell,SWT.PUSH);add.setText(add trains);add.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)new AddTrain(tm););Button update=new Button(tmshell,SWT.PUSH);update.setText(modify);update.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)TableItem selection=table.getSelection(); TableItem selectedRow=selection0; Train train=new Train(); train.setId(Integer.parseInt(selectedRow.getText(0); train.setTrainNum(selectedRow.getText(1); train.setTrainType(selectedRow.getText(2); train.setStarting(selectedRow.getText(3); train.setStartingTime(selectedRow.getText(4); train.setTerminal(selectedRow.getText(5); train.setTerminalTime(selectedRow.getText(6); train.setIskongTiao(selectedRow.getText(7); train.setPrice(Float.parseFloat(selectedRow.getText(8); train.setMiddleStation(selectedRow.getText(9); train.setYzNum(Integer.parseInt(selectedRow.getText(10); train.setRzNum(Integer.parseInt(selectedRow.getText(11); train.setYwNum(Integer.parseInt(selectedRow.getText(12); train.setRwNum(Integer.parseInt(selectedRow.getText(13); new UpdateTrain(train,tm););Button delete=new Button(tmshell,SWT.PUSH);delete.setText(cancel);delete.addSelectionListener(new SelectionAdapter()public void widgetSelected(SelectionEvent e)MessageBox box=new MessageBox(tmshell,SWT.YES|SWT.NO);box.setMessage(Are you sure to cancel?);int num=box.open();if(num=128)return ;TableItem selection=table.getSelection(); TableItem selectedRow=selection0; DAO dao=new DAO(); String sql=delete from train where id=+selectedRow.getText(0)+; int i=dao.update(sql); if(i0) box.setMessage(succeed); box.open(); table.remove(table.getSelectionIndex(); else box.setMessage(failure); box.open(); );tmshell.setSize(1200,400);tmshell.setText(train Management);tmshell.open(); while(!tmshell.isDisposed() if(!display.readAndDispatch() display.sleep(); tmshell.dispose();public void freshData()table.removeAll();tryDAO dao=new DAO();List list=dao.getAllTrain();int number=list.size();for(int i=0;ilist.size();i+)Train train=(Train)list.get(i);final TableItem item=new TableItemnumber;itemi=new TableItem(table,SWT.None);itemi.setText(new StringInteger.toString(train.getId(),train.getTrainNum(),train.getTrainType(),train.getStarting(),train.getStartingTime(),train.getTerminal(),train.getTerminalTime(),train.getIskongTiao(),Float.toString(train.getPrice(),train.getMiddleStation(),Integer.toString(train.getYzNum(),Integer.toString(train.getRzNum(),Integer.toString(train.getYwNum(),Integer.toString(train.getYwNum();catch(Exception e)e.printStackTrace();在该段代码中调用了DAO.java类中的getAllTrain()方法来获得所有的车辆信息,然后以表格的形式显示出来。DAO.java类中的getAllTrain()和update()方法如下:public int update(String sql)int i=0;con=Conn.getConnection();try pt=con.prepareStatement(sql);i=pt.executeUpdate(); catch (SQLException e) e.printStackTrace();finallyConn.closePt(pt);Conn.closeCon(con);return i;public List getAllTrain()List list=new ArrayList();con=Conn.getConnection();try pt=con.prepareStatement(select * from train);rs=pt.executeQuery();while(rs.next()Train train=new Train();train.setId(rs.getInt(1);train.setTrainNum(rs.getString(2);train.setTrainType(rs.getString(3);train.setStarting(rs.getString(4);train.setStartingTime(rs.getString(5);train.setTerminal(rs.getString(6);train.setTerminalTime(rs.getString(7);train.setIskongTiao(rs.getString(8);train.setPrice(rs.getFloat(9);train.setMiddleStation(rs.getString(10);train.setYzNum(rs.getInt(11);train.setRzNum(rs.getInt(12);train.setYwNum(rs.getInt(13);train.setRwNum(rs.getInt(14);list.add(train); catch (SQLException e) e.printStackTrace();finallyConn.closeRs(rs);Conn.closePt(pt);Conn.closeCon(con);return list;其中的update的功能是,首先连接数据库,然后用传递过来的SQl语句在列表中删除某辆列车的信息。getAllTrain()方法是显示所有的列车的信息。图示如下:在车次管理中的对于列车信息添加的功能是通过AddTrain.java 来实现的。代码如下:import org.eclipse.swt.SWT;import org.eclipse.swt.events.*;import org.eclipse.swt.layout.*;import org.eclipse.swt.widgets.*;import com.huizhi.dao.DAO;public class AddTrain Display display=Display.getCurrent(); Shell tmshell=new Shell(display); TrainManage trainmanage=null; public AddTrain(TrainManage tm) trainmanage=tm; GridLayout gridlayout=new GridLayout(); tmshell.setText(add trains information); gridlayout.numColumns=2; gridlayout.makeColumnsEqualWidth=true; tmshell.setLayout(gridlayout); GridData gd = new GridData(GridData.FILL_BOTH); Label l=new Label(tmshell,SWT.LEFT); l.setText(trainNum); l.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text trainNum=new Text(tmshell,S

温馨提示

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

评论

0/150

提交评论