人人范文网 范文大全

软件项目开发总结报告

发布时间:2020-03-03 20:39:10 来源:范文大全 收藏本文 下载本文 手机版

武汉理工大学《软件开发工具》论文报告

火车票系统的开发

1引言

研究报告(1.研究计划;2.完成的研究内容、研究方法、研究过程与结论、成果;3.比照研究计划,分析超过或未达到预定目标、进度、研究内容的原因;4.参考文献等。)

随着人们生活水平和经济水平的提高,网络科技的全球化的发展,出游和出差的频率越来越多。这大大的激发了交通水平的发展。其中,火车这种又方便有便宜的交通工具作为人们的首选,火车站的客运列车增加,客运量也随之增加。原有的售票的方式已经不再能满足旅客的需求了。为了方便旅客售票系统不仅仅只能售票也能够了解列车的各种信息。这样才能成为现在网络社会的真的适应者。

2需求分析

该售票系统是融合了火车票销售、退票、列车管理、车票管理、售票员管理、列车管理信息,以及售票信息查询为一体的综合系统。该系统主要编写的功能是列车和售票信息的查询及售票功能。

2.1用户

该系统主要有两类用户:管理员和售票员。管理员主要工作有车次管理,车票管理和售票员管理。对于每项功能都有添加,删除和修改的功能。售票的主要工作是售票和退票。

2.2主要功能

该系统从功能方面可以分为四个方面: 登录。不管你是管理员还是售票员必须登录以后才可以进行系统允许的操作。当然要登录的管理员和售票员都必须是再数据库中已经发布的。

基本设置:该模块主要是修改售票员的相关信息,修改列车的相关信息和修改车票的相

武汉理工大学《软件开发工具》论文报告

关信息。这一块的功能只有管理员才可以操作。其他的售票员是不可以对他进行操作的。

售票和退票:这部分工作主要是售票员来操作的。售票员根据买票人员提出的要求进行查询。查询的方式有两种:一是根据车次查询;一是根据目的地来查询。退票主要是将已经出售的车票在列车开出之前再一次的返回到数据库中,并继续出售。

列车和车票查询;当需要查询列车信息或者是车票信息是所做的操作。

2.3基本流程

3开发过程

3.1内容

该程序包括三个部分数据库的设计、通用模块的实现、各个模块的实现。

3.1.1 数据库的设计:

将本系统所需的所有的数据都存储到数据库中。需要在数据库中管理员表、

售票员表、列车信息表和车票信息表。如图所示:

武汉理工大学《软件开发工具》论文报告

管理员表:

售票员表:

列车信息表:

武汉理工大学《软件开发工具》论文报告

车票信息表:

3.1.2通用模块的实现:

通用模块为了减少代码的重复。在该系统中,对经常使用的操作进行封装,如将多次需要调用的数据库和操作数库的增、删、改和查等操作进行封装。使代码有很好的重用性,即使出现错误也很容易调试。 如本程序中的Conn.java

import java.sql.*; public cla 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\"; static{

} public static Connection getConnection(){

} public static void closeCon(Connection con){

try { if(con!=null) con.close(); try {

} return con; con=DriverManager.getConnection(URL,NAME,PASSWORD); e.printStackTrace(); } catch (SQLException e) { try {

} Cla.forName(DRIVER); e.printStackTrace(); } catch (ClaNotFoundException e) { } catch (SQLException e) { 4

武汉理工大学《软件开发工具》论文报告

}

} public static void closePt(PreparedStatement pt){

} public static void closeRs(ResultSet rs){

} try {

} if(rs!=null) rs.close(); try {

} if(pt!=null) pt.close(); } e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } 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 cla Login {

private Text nameText;

private Text paText;

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 paword = new Label(shell, SWT.NONE);

paword.setText(\"paword\");

paText = new Text(shell, SWT.SINGLE | SWT.BORDER| SWT.PASSWORD);

// paText.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 pa=paText.getText();

String sql=null;

boolean flag=false;

MeageBox box=new MeageBox(shell,SWT.OK);

if(\"\".equals(type)||\"\".equals(name)||\"\".equals(pa))

{

box.setMeage(\"please input all the information\");

box.open();

return ;

}

武汉理工大学《软件开发工具》论文报告

DAO dao=new DAO();

if(\"users\".equals(type)){

sql=\"select * from users where username=\'\"+name+\"\' and paword=\'\"+pa+\"\'\";

}else if(\"admin\".equals(type)){

sql=\"select * from admin where username=\'\"+name+\"\' and paword=\'\"+pa+\"\'\";

}

flag=dao.login(sql);

if(flag)

{

shell.dispose();

new Main(type);

}else{

box.setMeage(\"wrong name or paword\");

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);

paword.setLayoutData(data);

武汉理工大学《软件开发工具》论文报告

data = new FormData();

data.top = new FormAttachment(paword,0,SWT.CENTER);

data.left = new FormAttachment(nameText,0,SWT.LEFT);

paText.setLayoutData(data);

data=new FormData();

data.top=new FormAttachment(paword,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();

}finally{

Conn.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 cla 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; 11

武汉理工大学《软件开发工具》论文报告

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 cla 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); 12

武汉理工大学《软件开发工具》论文报告

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=selection[0];

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)); 13

武汉理工大学《软件开发工具》论文报告

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){

MeageBox box=new MeageBox(tmshell,SWT.YES|SWT.NO);

box.setMeage(\"Are you sure to cancel?\");

int num=box.open();

if(num==128)

return ;

TableItem[] selection=table.getSelection();

TableItem selectedRow=selection[0];

DAO dao=new DAO();

String sql=\"delete from train where id=\"+selectedRow.getText(0)+\"\";

int i=dao.update(sql);

if(i>0){

box.setMeage(\"succeed\");

box.open();

table.remove(table.getSelectionIndex());

}else{

box.setMeage(\"failure\");

box.open();

}

}

}); 14

武汉理工大学《软件开发工具》论文报告

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();

try{

DAO dao=new DAO();

List list=dao.getAllTrain();

int number=list.size();

for(int i=0;i

Train train=(Train)list.get(i);

final TableItem item[]=new TableItem[number];

item[i]=new TableItem(table,SWT.None);

item[i].setText(new

String[]{Integer.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) { 15

武汉理工大学《软件开发工具》论文报告

e.printStackTrace(); }finally{

Conn.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(); }finally{

Conn.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 cla 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,SWT.NONE); trainNum.setSize(50,60); trainNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l1=new Label(tmshell,SWT.LEFT); l1.setText(\"trainType\"); l1.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text trainType=new Text(tmshell,SWT.LEFT); 17

武汉理工大学《软件开发工具》论文报告

trainType.setSize(30,40); trainType.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l2=new Label(tmshell,SWT.LEFT); l2.setText(\"starting\"); l2.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text starting=new Text(tmshell,SWT.LEFT); starting.setSize(30,40); starting.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l3=new Label(tmshell,SWT.LEFT); l3.setText(\"startingtime\"); l3.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text startingTime=new Text(tmshell,SWT.LEFT); startingTime.setSize(30,40); startingTime.setLayoutData(gd); Label l4=new Label(tmshell,SWT.LEFT); l4.setText(\"terminal\"); l4.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text terminal=new Text(tmshell,SWT.LEFT); terminal.setSize(30,40); terminal.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l5=new Label(tmshell,SWT.LEFT); l5.setText(\"terminaltime\"); l5.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text terminalTime=new Text(tmshell,SWT.LEFT); terminalTime.setSize(30,40); terminalTime.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l6=new Label(tmshell,SWT.LEFT); l6.setText(\"iskongtiao\"); l6.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text iskongTiao=new Text(tmshell,SWT.LEFT); 18

武汉理工大学《软件开发工具》论文报告

iskongTiao.setSize(30,40); iskongTiao.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l7=new Label(tmshell,SWT.LEFT); l7.setText(\"price\"); l7.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text price=new Text(tmshell,SWT.LEFT); price.setSize(30,40); price.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l8=new Label(tmshell,SWT.LEFT); l8.setText(\"middleStation\"); l8.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text middleStation=new Text(tmshell,SWT.LEFT); middleStation.setSize(30,40); middleStation.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l9=new Label(tmshell,SWT.LEFT); l9.setText(\"yzNum\"); l9.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text yzNum=new Text(tmshell,SWT.LEFT); yzNum.setSize(30,40); yzNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l10=new Label(tmshell,SWT.LEFT); l10.setText(\"rzNum\"); l10.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text rzNum=new Text(tmshell,SWT.LEFT); rzNum.setSize(30,40); rzNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l11=new Label(tmshell,SWT.LEFT); l11.setText(\"ywNum\"); l11.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); 19

武汉理工大学《软件开发工具》论文报告

final Text ywNum=new Text(tmshell,SWT.LEFT); ywNum.setSize(30,40); ywNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l12=new Label(tmshell,SWT.LEFT); l12.setText(\"rwNum\"); l12.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text rwNum=new Text(tmshell,SWT.LEFT); rwNum.setSize(30,40); rwNum.setLayoutData(gd); Button b=new Button(tmshell,SWT.LEFT); b.setText(\"add\"); b.addSelectionListener(new SelectionAdapter(){

public void widgetSelected(SelectionEvent e){

MeageBox box = new MeageBox( tmshell ,SWT.OK);

if(\"\".equals(trainNum.getText())||\"\".equals(trainType.getText())||\"\".equals(starting.getText())

||\"\".equals(startingTime.getText())||\"\".equals(terminal.getText())||\"\".equals(terminalTime.getText())

||\"\".equals(iskongTiao.getText())||\"\".equals(price.getParent())||\"\".equals(middleStation.getText())||\"\".equals(yzNum.getText())

||\"\".equals(rzNum.getText())||\"\".equals(ywNum.getText())||\"\".equals(rwNum.getText())){

box.setMeage(\"please input the right information\");

box.open();

return ;

}

DAO dao=new DAO();

String sql=\"insert into train(trainNum,trainType,starting1,startingTime,terminal,terminalTime,iskongTiao,price,\" +

\"middleStation,yzNum,rzNum,ywNum,rwNum)values(\'\"+trainNum.getText()+\"\',\'\"+trainType.getText()+\"\',\'\"+starting.getText()+\"\',\" +

\"\'\"+startingTime.getText()+\"\',\'\"+terminal.getText()+\"\',\'\"+terminalTime.getText()+\"\',\'\"+iskongTiao.getText()+\"\',\" + 20

武汉理工大学《软件开发工具》论文报告

\"\'\"+price.getText()+\"\',\'\"+middleStation.getText()+\"\',\'\"+yzNum.getText()+\"\',\'\"+rzNum.getText()+\"\',\'\"+ywNum.getText()+\"\',\'\"+rwNum.getText()+\"\')\";

int i=dao.update(sql);

if(i>0){

box.setMeage(\"add\");

box.open();

fresh();

}

} }); Button b1=new Button(tmshell,SWT.LEFT); b1.setText(\"quit\"); b1.addSelectionListener(new SelectionAdapter(){

public void widgetSelected(SelectionEvent e){

tmshell.setVisible(false);

} }); tmshell.layout();

tmshell.setSize(500,450);

tmshell.open();

while(!tmshell.isDisposed()){

if(!display.readAndDispatch())

display.sleep();

}

tmshell.dispose(); } public void fresh(){

trainmanage.freshData(); } } 图示为:

21

武汉理工大学《软件开发工具》论文报告

修改列车功能是在UpdateTrain.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; import com.huizhi.vo.Train;

public cla UpdateTrain {

private Train train; Display display=Display.getCurrent(); Shell utrainshell=new Shell(display); TrainManage trainmanage=null; public UpdateTrain(Train train,TrainManage tm){ this.trainmanage=tm; this.train=train; GridLayout gridlayout=new GridLayout(); utrainshell.setText(\"modify train information\"); gridlayout.numColumns=2; gridlayout.makeColumnsEqualWidth=true; utrainshell.setLayout(gridlayout);

22

武汉理工大学《软件开发工具》论文报告

GridData gd = new GridData(GridData.FILL_BOTH); Label ll=new Label(utrainshell,SWT.LEFT); ll.setText(\"train ID\"); ll.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text num=new Text(utrainshell,SWT.NONE); num.setText(Integer.toString(train.getId())); num.setEnabled(false); num.setSize(50,60); num.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l=new Label(utrainshell,SWT.LEFT); l.setText(\"TrainNum\"); l.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text trainNum=new Text(utrainshell,SWT.NONE); trainNum.setText(train.getTrainNum()); trainNum.setSize(50,60); trainNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l1=new Label(utrainshell,SWT.LEFT); l1.setText(\"TrainType\"); l1.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text trainType=new Text(utrainshell,SWT.LEFT); trainType.setText(train.getTrainType()); trainType.setSize(30,40); trainType.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l2=new Label(utrainshell,SWT.LEFT); l2.setText(\"starting\"); l2.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text starting=new Text(utrainshell,SWT.LEFT); starting.setText(train.getStarting()); starting.setSize(30,40); starting.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l3=new Label(utrainshell,SWT.LEFT); l3.setText(\"startingTime\"); 23

武汉理工大学《软件开发工具》论文报告

l3.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text startingTime=new Text(utrainshell,SWT.LEFT); startingTime.setText(train.getStartingTime()); startingTime.setSize(30,40); startingTime.setLayoutData(gd); Label l4=new Label(utrainshell,SWT.LEFT); l4.setText(\"terminal\"); l4.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text terminal=new Text(utrainshell,SWT.LEFT); terminal.setText(train.getTerminal()); terminal.setSize(30,40); terminal.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l5=new Label(utrainshell,SWT.LEFT); l5.setText(\"terminalTime\"); l5.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text terminalTime=new Text(utrainshell,SWT.LEFT); terminalTime.setText(train.getTerminalTime()); terminalTime.setSize(30,40); terminalTime.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l6=new Label(utrainshell,SWT.LEFT); l6.setText(\"iskongtiao\"); l6.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text iskongTiao=new Text(utrainshell,SWT.LEFT); iskongTiao.setText(train.getIskongTiao()); iskongTiao.setSize(30,40); iskongTiao.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l7=new Label(utrainshell,SWT.LEFT); l7.setText(\"price\"); l7.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text price=new Text(utrainshell,SWT.LEFT); price.setText(Float.toString(train.getPrice())); price.setSize(30,40); 24

武汉理工大学《软件开发工具》论文报告

price.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l8=new Label(utrainshell,SWT.LEFT); l8.setText(\"middleStation\"); l8.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text middleStation=new Text(utrainshell,SWT.LEFT); middleStation.setText(train.getMiddleStation()); middleStation.setSize(30,40); middleStation.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l9=new Label(utrainshell,SWT.LEFT); l9.setText(\"yzNum\"); l9.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text yzNum=new Text(utrainshell,SWT.LEFT); yzNum.setText(Integer.toString(train.getYzNum())); yzNum.setSize(30,40); yzNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l10=new Label(utrainshell,SWT.LEFT); l10.setText(\"rzNum\"); l10.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text rzNum=new Text(utrainshell,SWT.LEFT); rzNum.setText(Integer.toString(train.getRzNum())); rzNum.setSize(30,40); rzNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l11=new Label(utrainshell,SWT.LEFT); l11.setText(\"ywNum\"); l11.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text ywNum=new Text(utrainshell,SWT.LEFT); ywNum.setText(Integer.toString(train.getYwNum())); ywNum.setSize(30,40); ywNum.setLayoutData(gd);

gd = new GridData(GridData.FILL_BOTH); Label l12=new Label(utrainshell,SWT.LEFT); 25

武汉理工大学《软件开发工具》论文报告

l12.setText(\"rwNum\"); l12.setLayoutData(gd); gd = new GridData(GridData.FILL_BOTH); final Text rwNum=new Text(utrainshell,SWT.LEFT); rwNum.setText(Integer.toString(train.getRwNum())); rwNum.setSize(30,40); rwNum.setLayoutData(gd); Button b=new Button(utrainshell,SWT.LEFT); b.setText(\"modify\"); b.addSelectionListener(new SelectionAdapter(){

public void widgetSelected(SelectionEvent e){

MeageBox box = new MeageBox( utrainshell ,SWT.OK);

if(\"\".equals(trainNum.getText())||\"\".equals(trainType.getText())||\"\".equals(starting.getText())

||\"\".equals(startingTime.getText())||\"\".equals(terminal.getText())||\"\".equals(terminalTime.getText())

||\"\".equals(iskongTiao.getText())||\"\".equals(price.getText())||\"\".equals(middleStation.getText())||\"\".equals(yzNum.getText())

||\"\".equals(rzNum.getText())||\"\".equals(ywNum.getText())||\"\".equals(rwNum.getText())){

box.setMeage(\"please input right information then modify \");

box.open();

return ;

}

DAO dao=new DAO();

String sql=\"update train set trainNum=\'\"+trainNum.getText()+\"\',trainType=\'\"+trainType.getText()+\"\',starting1=\'\"+starting.getText()+\"\',\" +

\"startingTime=\'\"+startingTime.getText()+\"\',terminal=\'\"+terminal.getText()+\"\',terminalTime=\'\"+terminalTime.getText()+\"\',iskongTiao=\'\"+iskongTiao.getText()+\"\',\" +

\"price=\'\"+price.getText()+\"\',middleStation=\'\"+middleStation.getText()+\"\',yzNum=\'\"+yzNum.getText()+\"\',rzNum=\'\"+rzNum.getText()+\"\',ywNum=\'\"+ywNum.getText()+\"\',rwNum=\'\"+rwNum.getText()+\"\' where id=\'\"+num.getText()+\"\'\";

int i=dao.update(sql);

if(i>0){ 26

武汉理工大学《软件开发工具》论文报告

box.setMeage(\"succeed\");

box.open();

fresh();

}else{

box.setMeage(\"failure\");

box.open();

}

} }); Button b1=new Button(utrainshell,SWT.LEFT); b1.setText(\"quit\"); b1.addSelectionListener(new SelectionAdapter(){

public void widgetSelected(SelectionEvent e){

utrainshell.setVisible(false);

} }); utrainshell.layout();

utrainshell.setSize(500,450);

utrainshell.open();

while(!utrainshell.isDisposed()){

if(!display.readAndDispatch())

display.sleep();

}

utrainshell.dispose(); } public void fresh(){

trainmanage.freshData(); } }

车票管理主要包括对车票的增加,删除和修改的操作。由TicketManagement.java 实现。代码类似上面的:(具体看压缩包)。其中的查询列车表和售票表调用的DAO.java类中selectTicket()方法。图示为:

27

武汉理工大学《软件开发工具》论文报告

售票员管理是对售票员进行增加、删除和修改进行操作。由UserMannage.java类来实现。代码类似以上。在该类中调用了DAO.java 类中getAllUser()方法。图示为:

28

武汉理工大学《软件开发工具》论文报告

售票及退票模块包括两部分:火车售票和退票。售票系统是xiaosTickect.java 实现的。图示如下:

退票是售票员根据用户提供的车票信息在系统中进行售票。主要是由TuiTicket.java来实现的。在该类中涉及到DAO.java类中的selectTrain()方法.图示如下:

列车及车票查询系统主要功能包括两部分:查询列车信息和查询车票信息.有FindTrain.Java和FindTicket.java 实现.图示如下:

29

武汉理工大学《软件开发工具》论文报告

4学习心得

我是再没有接触eclipse之前就接触了java,我自己都先用记事本编写java程序,然后在doc下进行编译和运行。后来安装了ecplise这个集成环境,但是只把它当成一个运行java的集成环境。

后来经过开发工具的学习和相关书籍的查看,开始深入的理解了什么是ecplise。其实整个ecplise体系结构就像一个大的拼图,可以不断地向其中添加插件,同时在现有的插件上还可以再增加插件。可以说,在ecplise中一切都是插件。这里有一张图片很形象的说明了ecplise的体系结构:

在我学习ecplise的工程中,我觉得它跟一般的软件比起来有很大的优势:在编写代码的过程中,如果有编译错误的话系统马上会提醒,我们很容易就会会发现。而且它会给你提供一些解决问题的方法,虽然有些解决方法有一些笨,但是这对于一些想我们这样的初学者来说,无疑是雪中送炭。而且在编写代码的过程中,我们使用一些类的对象的方法的过程中系统给予一定的提示。这大大的减少了我们出错的机会,并且我们也可以顺便了解一下该类的其他方法。加快我们的学习进度。

30

武汉理工大学《软件开发工具》论文报告

对于ecplise的具体的功能的学习感悟:对于调试器板块该环境提供了很多的功能包括单步执行、设置断点和值、检查变量和值以及暂挂和恢复线程的能力。在我们课堂上只学习了本地调试中的断点。断点提供了一种强大的工具,使我们能够在需要的时间和位置挂起执行。与逐句或逐条指令的检查代码不同的是,可以让程序一直执行,直到遇到断点。然后开始调试。这大大的加快了调试过程。没有这个功能,调试大型程序几乎不能完成。至于远程的调试对于现在学习的程度来说有一点难。所以先放弃,以后再研究。

对于JUnit,包括模块接口测试、局部数据结构测试、路经测试、错误处理测试、边界测试。它的核心类主要有jnuit.framework包下的TestCase、Testsuite和TestResult,junit.runnier包下的BaseTestRunner类。而我们现在用到的只有断言Aert。在这里有一点原则是需要注意的它的测试名要很容易与应用类区分开来。

我觉得学会用ecplise来创建的基于SWT的图形应用程序十分的重要。这个要源于它的开发缘由。在这之前,使用的awt是原生窗口部件,但是它一直未能突破LCD。为了解决这个问题,又开发了swing。它使用的是仿真窗口部件,不存在LCD问题。但是消耗太多的内存等。为了彻底解决

上述问题,IBM开发了SWT。在基于Windows的ecplise中,SWT通过DLL形式的本地库与操作系统交互;在UNIX下,SWT可通过的GTK运行。

最近的学习和看书,让我觉得自己的真的就像在软件的最顶层。自己现在学习的东西在软件

中真的是基础中的基础。我们还有很长的路要走。真的要加油,好好学习啊!

5.参考文献

[1]java核心技术卷1:基础知识 叶乃文 邝劲筠 杜永萍 2008.5 机械工业出版社 [2]eclipse 3.0 程序开发技术详解

吴越胜 李新磊

2010.10 清华大学出版社

31

附6 软件项目开发总结报告

软件项目总结报告

项目开发总结报告

项目开发总结报告

项目开发总结报告

项目开发总结报告

项目开发总结报告

开发项目总结报告

项目开发总结报告

项目开发总结报告

软件项目开发总结报告
《软件项目开发总结报告.doc》
将本文的Word文档下载到电脑,方便编辑。
推荐度:
点击下载文档
点击下载本文文档