軟件項目開發(fā)總結報告模版_第1頁
軟件項目開發(fā)總結報告模版_第2頁
軟件項目開發(fā)總結報告模版_第3頁
軟件項目開發(fā)總結報告模版_第4頁
軟件項目開發(fā)總結報告模版_第5頁
已閱讀5頁,還剩18頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

.z.火車票系統(tǒng)的開發(fā)1引言研究報告〔1.研究方案;2.完成的研究容、研究方法、研究過程與結論、成果;3.比照研究方案,分析超過或未到達預定目標、進度、研究容的原因;4.參考文獻等?!畴S著人們生活水平和經濟水平的提高,網(wǎng)絡科技的全球化的開展,出游和出差的頻率越來越多。這大大的激發(fā)了交通水平的開展。其中,火車這種又方便有廉價的交通工具作為人們的首選,火車站的客運列車增加,客運量也隨之增加。原有的售票的方式已經不再能滿足旅客的需求了。為了方便旅客售票系統(tǒng)不僅僅只能售票也能夠了解列車的各種信息。這樣才能成為現(xiàn)在網(wǎng)絡社會的真的適應者。2需求分析該售票系統(tǒng)是融合了火車票銷售、退票、列車管理、車票管理、售票員管理、列車管理信息,以及售票信息查詢?yōu)橐惑w的綜合系統(tǒng)。該系統(tǒng)主要編寫的功能是列車和售票信息的查詢及售票功能。2.1用戶該系統(tǒng)主要有兩類用戶:管理員和售票員。管理員主要工作有車次管理,車票管理和售票員管理。對于每項功能都有添加,刪除和修改的功能。售票的主要工作是售票和退票。2.2主要功能該系統(tǒng)從功能方面可以分為四個方面:登錄。不管你是管理員還是售票員必須登錄以后才可以進展系統(tǒng)允許的操作。當然要登錄的管理員和售票員都必須是再數(shù)據(jù)庫中已經發(fā)布的。根本設置:該模塊主要是修改售票員的相關信息,修改列車的相關信息和修改車票的相關信息。這一塊的功能只有管理員才可以操作。其他的售票員是不可以對他進展操作的。售票和退票:這局部工作主要是售票員來操作的。售票員根據(jù)買票人員提出的要求進展查詢。查詢的方式有兩種:一是根據(jù)車次查詢;一是根據(jù)目的地來查詢。退票主要是將已經出售的車票在列車開出之前再一次的返回到數(shù)據(jù)庫中,并繼續(xù)出售。列車和車票查詢;當需要查詢列車信息或者是車票信息是所做的操作。2.3根本流程3開發(fā)過程3.1容該程序包括三個局部數(shù)據(jù)庫的設計、通用模塊的實現(xiàn)、各個模塊的實現(xiàn)。3.1.1數(shù)據(jù)庫的設計:將本系統(tǒng)所需的所有的數(shù)據(jù)都存儲到數(shù)據(jù)庫中。需要在數(shù)據(jù)庫中管理員表、售票員表、列車信息表和車票信息表。如下圖:管理員表:售票員表:列車信息表:車票信息表:3.1.2通用模塊的實現(xiàn):通用模塊為了減少代碼的重復。在該系統(tǒng)中,對經常使用的操作進展封裝,如將屢次需要調用的數(shù)據(jù)庫和操作數(shù)庫的增、刪、改和查等操作進展封裝。使代碼有很好的重用性,即使出現(xiàn)錯誤也很容易調試。如本程序中的Conn.javaimportjava.sql.*;publicclassConn{privatestaticConnectioncon;privatestaticfinalStringDRIVER=".mysql.jdbc.Driver";privatestaticfinalStringURL="jdbc:mysql://localhost:3306/newdatabase";privatestaticfinalStringNAME="root";privatestaticfinalStringPASSWORD="4";static{try{ Class.forName(DRIVER); }catch(ClassNotFoundE*ceptione){ e.printStackTrace(); } }publicstaticConnectiongetConnection(){try{con=DriverManager.getConnection(URL,NAME,PASSWORD); }catch(SQLE*ceptione){ e.printStackTrace(); }returncon; }publicstaticvoidcloseCon(Connectioncon){try{if(con!=null) con.close(); }catch(SQLE*ceptione){ e.printStackTrace(); } }publicstaticvoidclosePt(PreparedStatementpt){try{if(pt!=null) pt.close(); }catch(E*ceptione){ e.printStackTrace(); } }publicstaticvoidcloseRs(ResultSetrs){try{if(rs!=null) rs.close(); }catch(E*ceptione){ e.printStackTrace(); } }}用戶登錄界面的設計、主界面的設計、根本設置模塊、銷售及退票模塊和列車及車票查詢模塊。用戶登錄模塊:該局部是通過設計login.java來實現(xiàn)的。這局部代碼的作用是用戶首先選擇自己的登錄的是管理員還是售票員,然后輸入賬號和密碼。單擊登錄,用戶先判斷用戶登錄的類型,然后給sql變量賦SQL語句值,系統(tǒng)調用DAO.java類的login〔〕傳入sql變量。.Login代碼是:importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.*;importorg.eclipse.swt.graphics.Image;importorg.eclipse.swt.layout.*;importorg.eclipse.swt.widgets.*;import.huizhi.dao.DAO;publicclassLogin{ privateTe*tnameTe*t; privateTe*tpassTe*t; privatebobo; privateStringtype; privateDisplaydisplay=newDisplay(); privateShellshell=newShell(display); publicLogin(){ FormLayoutlayout=newFormLayout(); layout.marginHeight=40; layout.marginWidth=40; shell.setLayout(layout); shell.setTe*t("login"); Imageimage=newImage(display,"2.jpg"); shell.setBackgroundImage(image); setUIControl(); shell.pack(); shell.open(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } display.dispose(); } privatevoidsetUIControl(){ Labelusername=newLabel(shell,SWT.NONE); username.setTe*t("username"); nameTe*t=newTe*t(shell,SWT.SINGLE|SWT.BORDER); Labelpassword=newLabel(shell,SWT.NONE); password.setTe*t("password"); passTe*t=newTe*t(shell,SWT.SINGLE|SWT.BORDER|SWT.PASSWORD); //passTe*t.setEchoChar('*'); Labelselect=newLabel(shell,SWT.NONE); select.setTe*t("select"); Buttonsubmit=newButton(shell,SWT.PUSH); submit.setTe*t("login"); submit.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ type=bo.getTe*t(); Stringname=nameTe*t.getTe*t(); Stringpass=passTe*t.getTe*t(); Stringsql=null; booleanflag=false; MessageBo*bo*=newMessageBo*(shell,SWT.OK); if("".equals(type)||"".equals(name)||"".equals(pass)) { bo*.setMessage("pleaseinputalltheinformation"); bo*.open(); return; } DAOdao=newDAO(); if("users".equals(type)){ sql="select*fromuserswhereusername='"+name+"'andpassword='"+pass+"'"; }elseif("admin".equals(type)){ sql="select*fromadminwhereusername='"+name+"'andpassword='"+pass+"'"; } flag=dao.login(sql); if(flag) { shell.dispose(); newMain(type); }else{ bo*.setMessage("wrongnameorpassword"); bo*.open(); } } }); Buttonreset=newButton(shell,SWT.PUSH); reset.setTe*t("cancel"); Stringvalue[]={"users","admin"}; bo=newbo(shell,SWT.DROP_DOWN); bo.setItems(value); FormDatadata=newFormData(); data.top=newFormAttachment(30,0); username.setLayoutData(data); data=newFormData(); data.top=newFormAttachment(username,0,SWT.CENTER); data.left=newFormAttachment(username,10,SWT.RIGHT); nameTe*t.setLayoutData(data); data=newFormData(); data.top=newFormAttachment(select,0,SWT.CENTER); data.left=newFormAttachment(select,10,SWT.RIGHT); bo.setLayoutData(data); data=newFormData(); data.top=newFormAttachment(username,10,SWT.BOTTOM); password.setLayoutData(data); data=newFormData(); data.top=newFormAttachment(password,0,SWT.CENTER); data.left=newFormAttachment(nameTe*t,0,SWT.LEFT); passTe*t.setLayoutData(data); data=newFormData(); data.top=newFormAttachment(password,10,SWT.BOTTOM); submit.setLayoutData(data); data=newFormData(); data.top=newFormAttachment(submit,0,SWT.CENTER); data.left=newFormAttachment(submit,20,SWT.RIGHT); reset.setLayoutData(data); } publicstaticvoidmain(String[]args){ newLogin(); }}DAO.java的login〔〕代碼: publicbooleanlogin(Stringsql){ booleanflag=false; con=Conn.getConnection(); try{ pt=con.prepareStatement(sql); rs=pt.e*ecuteQuery(); if(rs.ne*t()){ flag=true; } }catch(SQLE*ceptione){ e.printStackTrace(); }finally{ Conn.closeRs(rs); Conn.closePt(pt); Conn.closeCon(con); } returnflag; }圖示為;實現(xiàn)主界面:importorg.eclipse.swt.*;importorg.eclipse.swt.widgets.*;importorg.eclipse.swt.layout.*;importorg.eclipse.swt.events.*;publicclassMain{ privateStringtype; Displaydisplay=Display.getCurrent(); Shellshell=newShell(display); publicMain(Stringtype){ this.type=type; shell.setTe*t("Trainticketingsystem"); shell.setLayout(newFillLayout());Menumenu=newMenu(shell,SWT.BAR);//第一個菜單 MenuItembasic=newMenuItem(menu,SWT.CASCADE); basic.setTe*t("BasicSettings"); if("users".equals(type)) { basic.setEnabled(false); } Menufilemenu=newMenu(shell,SWT.DROP_DOWN); MenuItemtrain=newMenuItem(filemenu,SWT.PUSH); train.setTe*t("TrainsManagement"); train.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ newTrainManage(); } }); MenuItemticket=newMenuItem(filemenu,SWT.PUSH); ticket.setTe*t("TicketsManagement"); ticket.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ newTicketManage(); } }); MenuItemusers=newMenuItem(filemenu,SWT.PUSH); users.setTe*t("UsersManagement"); users.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ newUsersManage(); } }); MenuIteme*it=newMenuItem(filemenu,SWT.PUSH); e*it.setTe*t("quit"); basic.setMenu(filemenu); e*it.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ display.dispose(); } }); //第二個菜單 MenuItemmarket=newMenuItem(menu,SWT.CASCADE); market.setTe*t("SalesandRefunds"); MenueditMenu=newMenu(shell,SWT.DROP_DOWN); MenuItemmarketItem=newMenuItem(editMenu,SWT.PUSH); marketItem.setTe*t("SalesTickets"); marketItem.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ new*iaosTicket(); } }); MenuItemrefundItem=newMenuItem(editMenu,SWT.PUSH); refundItem.setTe*t("RefundsTickets"); market.setMenu(editMenu); refundItem.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ newTuiTicket(); } });//第三個菜單 MenuItemfind=newMenuItem(menu,SWT.CASCADE); find.setTe*t("TrainsandTicketsquery"); MenutaiMenu=newMenu(shell,SWT.DROP_DOWN); MenuItemtrainFind=newMenuItem(taiMenu,SWT.PUSH); trainFind.setTe*t("Trainsquery"); trainFind.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ newFindTrain(); } }); MenuItemticketFind=newMenuItem(taiMenu,SWT.PUSH); ticketFind.setTe*t("Ticketquery"); find.setMenu(taiMenu); ticketFind.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(SelectionEvente){ newFindTicket(); } }); shell.setMenuBar(menu); shell.setSize(500,400); shell.open(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } display.dispose(); }}圖示為:根本設置模塊包括車次管理,車票管理和售票員管理。車次管理主要是是對于列車的增加,刪除和修改等操作。其中包括它的相關的信息等。它是由TrainManagement.java.代碼如下:importjava.util.List;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.*;importorg.eclipse.swt.layout.*;importorg.eclipse.swt.widgets.*;import.huizhi.dao.DAO;import.huizhi.vo.Train;publicclassTrainManage{ Displaydisplay=Display.getCurrent(); Shelltmshell=newShell(display);finalTabletable=newTable(tmshell,SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER|SWT.FULL_SELECTION); TrainManagetm=this;publicTrainManage(){ RowLayoutrowLayout=newRowLayout(); rowLayout.pack=true; rowLayout.wrap=true; rowLayout.justify=false; rowLayout.marginTop=20;tmshell.setLayout(rowLayout);finalTableColumncolumn1=newTableColumn(table,SWT.LEFT); column1.setTe*t("TrainID"); column1.setWidth(80);finalTableColumncolumn2=newTableColumn(table,SWT.LEFT); column2.setTe*t("TrainNum"); column2.setWidth(80);finalTableColumncolumn3=newTableColumn(table,SWT.LEFT); column3.setTe*t("TrainType"); column3.setWidth(80);finalTableColumncolumn4=newTableColumn(table,SWT.LEFT); column4.setTe*t("Starting"); column4.setWidth(80);finalTableColumncolumn5=newTableColumn(table,SWT.LEFT); column5.setTe*t("startingTime"); column5.setWidth(80);finalTableColumncolumn6=newTableColumn(table,SWT.LEFT); column6.setTe*t("terminal"); column6.setWidth(80);finalTableColumncolumn7=newTableColumn(table,SWT.LEFT); column7.setTe*t("terminalTime"); column7.setWidth(80);finalTableColumncolumn8=newTableColumn(table,SWT.LEFT); column8.setTe*t("iskongtiao"); column8.setWidth(80);finalTableColumncolumn9=newTableColumn(table,SWT.LEFT); column9.setTe*t("price"); column9.setWidth(80);finalTableColumncolumn10=newTableColumn(table,SWT.LEFT); column10.setTe*t("middleStation"); column10.setWidth(80);finalTableColumncolumn11=newTableColumn(table,SWT.LEFT); column11.setTe*t("yzNum"); column11.setWidth(80);finalTableColumncolumn12=newTableColumn(table,SWT.LEFT); column12.setTe*t("rzNum"); column12.setWidth(80);finalTableColumncolumn13=newTableColumn(table,SWT.LEFT); column13.setTe*t("ywNum"); column13.setWidth(80);finalTableColumncolumn14=newTableColumn(table,SWT.LEFT); column14.setTe*t("rwNum"); column14.setWidth(80);table.setHeaderVisible(true);table.setLinesVisible(true); freshData();table.setSize(800,200); Buttonadd=newButton(tmshell,SWT.PUSH); add.setTe*t("addtrains"); add.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(SelectionEvente){newAddTrain(tm); } }); Buttonupdate=newButton(tmshell,SWT.PUSH); update.setTe*t("modify"); update.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(SelectionEvente){ TableItem[]selection=table.getSelection(); TableItemselectedRow=selection[0]; Traintrain=newTrain(); train.setId(Integer.parseInt(selectedRow.getTe*t(0))); train.setTrainNum(selectedRow.getTe*t(1)); train.setTrainType(selectedRow.getTe*t(2)); train.setStarting(selectedRow.getTe*t(3)); train.setStartingTime(selectedRow.getTe*t(4)); train.setTerminal(selectedRow.getTe*t(5)); train.setTerminalTime(selectedRow.getTe*t(6)); train.setIskongTiao(selectedRow.getTe*t(7)); train.setPrice(Float.parseFloat(selectedRow.getTe*t(8))); train.setMiddleStation(selectedRow.getTe*t(9)); train.setYzNum(Integer.parseInt(selectedRow.getTe*t(10))); train.setRzNum(Integer.parseInt(selectedRow.getTe*t(11))); train.setYwNum(Integer.parseInt(selectedRow.getTe*t(12))); train.setRwNum(Integer.parseInt(selectedRow.getTe*t(13)));newUpdateTrain(train,tm); } }); Buttondelete=newButton(tmshell,SWT.PUSH); delete.setTe*t("cancel"); delete.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(SelectionEvente){ MessageBo*bo*=newMessageBo*(tmshell,SWT.YES|SWT.NO); bo*.setMessage("Areyousuretocancel"");intnum=bo*.open();if(num==128)return; TableItem[]selection=table.getSelection(); TableItemselectedRow=selection[0]; DAOdao=newDAO(); Stringsql="deletefromtrainwhereid="+selectedRow.getTe*t(0)+"";inti=dao.update(sql);if(i>0){ bo*.setMessage("succeed"); bo*.open();table.remove(table.getSelectionInde*()); }else{ bo*.setMessage("failure"); bo*.open(); } } });tmshell.setSize(1200,400);tmshell.setTe*t("trainManagement");tmshell.open();while(!tmshell.isDisposed()){if(!display.readAndDispatch())display.sleep(); }tmshell.dispose(); }publicvoidfreshData(){table.removeAll();try{ DAOdao=newDAO();Listlist=dao.getAllTrain();intnumber=list.size();for(inti=0;i<list.size();i++){ Traintrain=(Train)list.get(i);finalTableItemitem[]=newTableItem[number]; item[i]=newTableItem(table,SWT.None); item[i].setTe*t(newString[]{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(E*ceptione){ e.printStackTrace(); } }}在該段代碼中調用了DAO.java類中的getAllTrain〔〕方法來獲得所有的車輛信息,然后以表格的形式顯示出來。DAO.java類中的getAllTrain〔〕和update〔〕方法如下:publicintupdate(Stringsql){inti=0;con=Conn.getConnection();try{pt=con.prepareStatement(sql); i=pt.e*ecuteUpdate(); }catch(SQLE*ceptione){ e.printStackTrace(); }finally{ Conn.closePt(pt); Conn.closeCon(con); }returni; }publicListgetAllTrain(){Listlist=newArrayList();con=Conn.getConnection();try{pt=con.prepareStatement("select*fromtrain");rs=pt.e*ecuteQuery();while(rs.ne*t()){ Traintrain=newTrain(); 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(SQLE*ceptione){ e.printStackTrace(); }finally{ Conn.closeRs(rs); Conn.closePt(pt); Conn.closeCon(con);}returnlist; }其中的update的功能是,首先連接數(shù)據(jù)庫,然后用傳遞過來的SQl語句在列表中刪除*輛列車的信息。getAllTrain〔〕方法是顯示所有的列車的信息。圖示如下:在車次管理中的對于列車信息添加的功能是通過AddTrain.java來實現(xiàn)的。代碼如下:importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.*;importorg.eclipse.swt.layout.*;importorg.eclipse.swt.widgets.*;import.huizhi.dao.DAO;publicclassAddTrain{Displaydisplay=Display.getCurrent();Shelltmshell=newShell(display);TrainManagetrainmanage=null;publicAddTrain(TrainManagetm){trainmanage=tm; GridLayoutgridlayout=newGridLayout();tmshell.setTe*t("addtrainsinformation"); gridlayout.numColumns=2; gridlayout.makeColumnsEqualWidth=true;tmshell.setLayout(gridlayout); GridDatagd=newGridData(GridData.FILL_BOTH); Labell=newLabel(tmshell,SWT.LEFT); l.setTe*t("trainNum"); l.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*ttrainNum=newTe*t(tmshell,SWT.NONE); trainNum.setSize(50,60); trainNum.setLayoutData(gd);gd=newGridData(GridData.FILL_BOTH); Labell1=newLabel(tmshell,SWT.LEFT); l1.setTe*t("trainType"); l1.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*ttrainType=newTe*t(tmshell,SWT.LEFT); trainType.setSize(30,40); trainType.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell2=newLabel(tmshell,SWT.LEFT); l2.setTe*t("starting"); l2.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tstarting=newTe*t(tmshell,SWT.LEFT); starting.setSize(30,40); starting.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell3=newLabel(tmshell,SWT.LEFT); l3.setTe*t("startingtime"); l3.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tstartingTime=newTe*t(tmshell,SWT.LEFT); startingTime.setSize(30,40); startingTime.setLayoutData(gd); Labell4=newLabel(tmshell,SWT.LEFT); l4.setTe*t("terminal"); l4.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tterminal=newTe*t(tmshell,SWT.LEFT); terminal.setSize(30,40); terminal.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell5=newLabel(tmshell,SWT.LEFT); l5.setTe*t("terminaltime"); l5.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tterminalTime=newTe*t(tmshell,SWT.LEFT); terminalTime.setSize(30,40); terminalTime.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell6=newLabel(tmshell,SWT.LEFT); l6.setTe*t("iskongtiao"); l6.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tiskongTiao=newTe*t(tmshell,SWT.LEFT); iskongTiao.setSize(30,40); iskongTiao.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell7=newLabel(tmshell,SWT.LEFT); l7.setTe*t("price"); l7.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tprice=newTe*t(tmshell,SWT.LEFT); price.setSize(30,40); price.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell8=newLabel(tmshell,SWT.LEFT); l8.setTe*t("middleStation"); l8.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tmiddleStation=newTe*t(tmshell,SWT.LEFT); middleStation.setSize(30,40); middleStation.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell9=newLabel(tmshell,SWT.LEFT); l9.setTe*t("yzNum"); l9.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tyzNum=newTe*t(tmshell,SWT.LEFT); yzNum.setSize(30,40); yzNum.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell10=newLabel(tmshell,SWT.LEFT); l10.setTe*t("rzNum"); l10.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*trzNum=newTe*t(tmshell,SWT.LEFT); rzNum.setSize(30,40); rzNum.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell11=newLabel(tmshell,SWT.LEFT); l11.setTe*t("ywNum"); l11.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tywNum=newTe*t(tmshell,SWT.LEFT); ywNum.setSize(30,40); ywNum.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell12=newLabel(tmshell,SWT.LEFT); l12.setTe*t("rwNum"); l12.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*trwNum=newTe*t(tmshell,SWT.LEFT); rwNum.setSize(30,40); rwNum.setLayoutData(gd); Buttonb=newButton(tmshell,SWT.LEFT); b.setTe*t("add"); b.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(SelectionEvente){ MessageBo*bo*=newMessageBo*(tmshell,SWT.OK);if("".equals(trainNum.getTe*t())||"".equals(trainType.getTe*t())||"".equals(starting.getTe*t()) ||"".equals(startingTime.getTe*t())||"".equals(terminal.getTe*t())||"".equals(terminalTime.getTe*t()) ||"".equals(iskongTiao.getTe*t())||"".equals(price.getParent())||"".equals(middleStation.getTe*t())||"".equals(yzNum.getTe*t()) ||"".equals(rzNum.getTe*t())||"".equals(ywNum.getTe*t())||"".equals(rwNum.getTe*t())){ bo*.setMessage("pleaseinputtherightinformation"); bo*.open();return; } DAOdao=newDAO(); Stringsql="insertintotrain(trainNum,trainType,starting1,startingTime,terminal,terminalTime,iskongTiao,price,"+"middleStation,yzNum,rzNum,ywNum,rwNum)values('"+trainNum.getTe*t()+"','"+trainType.getTe*t()+"','"+starting.getTe*t()+"',"+"'"+startingTime.getTe*t()+"','"+terminal.getTe*t()+"','"+terminalTime.getTe*t()+"','"+iskongTiao.getTe*t()+"',"+"'"+price.getTe*t()+"','"+middleStation.getTe*t()+"','"+yzNum.getTe*t()+"','"+rzNum.getTe*t()+"','"+ywNum.getTe*t()+"','"+rwNum.getTe*t()+"')";inti=dao.update(sql);if(i>0){ bo*.setMessage("add"); bo*.open(); fresh(); } } }); Buttonb1=newButton(tmshell,SWT.LEFT); b1.setTe*t("quit"); b1.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(SelectionEvente){tmshell.setVisible(false); } });tmshell.layout();tmshell.setSize(500,450);tmshell.open();while(!tmshell.isDisposed()){if(!display.readAndDispatch())display.sleep(); }tmshell.dispose();}publicvoidfresh(){trainmanage.freshData();}}圖示為:修改列車功能是在UpdateTrain.java.類中實現(xiàn)的。代碼如下:importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.*;importorg.eclipse.swt.layout.*;importorg.eclipse.swt.widgets.*;import.huizhi.dao.DAO;import.huizhi.vo.Train;publicclassUpdateTrain{privateTraintrain;Displaydisplay=Display.getCurrent();Shellutrainshell=newShell(display);TrainManagetrainmanage=null;publicUpdateTrain(Traintrain,TrainManagetm){this.trainmanage=tm;this.train=train; GridLayoutgridlayout=newGridLayout();utrainshell.setTe*t("modifytraininformation"); gridlayout.numColumns=2; gridlayout.makeColumnsEqualWidth=true;utrainshell.setLayout(gridlayout); GridDatagd=newGridData(GridData.FILL_BOTH); Labelll=newLabel(utrainshell,SWT.LEFT); ll.setTe*t("trainID"); ll.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tnum=newTe*t(utrainshell,SWT.NONE); num.setTe*t(Integer.toString(train.getId())); num.setEnabled(false); num.setSize(50,60); num.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell=newLabel(utrainshell,SWT.LEFT); l.setTe*t("TrainNum"); l.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*ttrainNum=newTe*t(utrainshell,SWT.NONE); trainNum.setTe*t(train.getTrainNum()); trainNum.setSize(50,60); trainNum.setLayoutData(gd);gd=newGridData(GridData.FILL_BOTH); Labell1=newLabel(utrainshell,SWT.LEFT); l1.setTe*t("TrainType"); l1.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*ttrainType=newTe*t(utrainshell,SWT.LEFT); trainType.setTe*t(train.getTrainType()); trainType.setSize(30,40); trainType.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell2=newLabel(utrainshell,SWT.LEFT); l2.setTe*t("starting"); l2.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tstarting=newTe*t(utrainshell,SWT.LEFT); starting.setTe*t(train.getStarting()); starting.setSize(30,40); starting.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell3=newLabel(utrainshell,SWT.LEFT); l3.setTe*t("startingTime"); l3.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tstartingTime=newTe*t(utrainshell,SWT.LEFT); startingTime.setTe*t(train.getStartingTime()); startingTime.setSize(30,40); startingTime.setLayoutData(gd); Labell4=newLabel(utrainshell,SWT.LEFT); l4.setTe*t("terminal"); l4.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tterminal=newTe*t(utrainshell,SWT.LEFT); terminal.setTe*t(train.getTerminal()); terminal.setSize(30,40); terminal.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell5=newLabel(utrainshell,SWT.LEFT); l5.setTe*t("terminalTime"); l5.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tterminalTime=newTe*t(utrainshell,SWT.LEFT); terminalTime.setTe*t(train.getTerminalTime()); terminalTime.setSize(30,40); terminalTime.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell6=newLabel(utrainshell,SWT.LEFT); l6.setTe*t("iskongtiao"); l6.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tiskongTiao=newTe*t(utrainshell,SWT.LEFT); iskongTiao.setTe*t(train.getIskongTiao()); iskongTiao.setSize(30,40); iskongTiao.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell7=newLabel(utrainshell,SWT.LEFT); l7.setTe*t("price"); l7.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tprice=newTe*t(utrainshell,SWT.LEFT); price.setTe*t(Float.toString(train.getPrice())); price.setSize(30,40); price.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell8=newLabel(utrainshell,SWT.LEFT); l8.setTe*t("middleStation"); l8.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tmiddleStation=newTe*t(utrainshell,SWT.LEFT); middleStation.setTe*t(train.getMiddleStation()); middleStation.setSize(30,40); middleStation.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell9=newLabel(utrainshell,SWT.LEFT); l9.setTe*t("yzNum"); l9.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tyzNum=newTe*t(utrainshell,SWT.LEFT); yzNum.setTe*t(Integer.toString(train.getYzNum())); yzNum.setSize(30,40); yzNum.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell10=newLabel(utrainshell,SWT.LEFT);l10.setTe*t("rzNum"); l10.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*trzNum=newTe*t(utrainshell,SWT.LEFT); rzNum.setTe*t(Integer.toString(train.getRzNum())); rzNum.setSize(30,40); rzNum.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH); Labell11=newLabel(utrainshell,SWT.LEFT); l11.setTe*t("ywNum"); l11.setLayoutData(gd); gd=newGridData(GridData.FILL_BOTH);finalTe*tywNum=newTe*t(utrainshell,SWT.LEFT); ywNum.setTe*t(Integ

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論