java蓝宇快递打印系统文档格式.docx
《java蓝宇快递打印系统文档格式.docx》由会员分享,可在线阅读,更多相关《java蓝宇快递打印系统文档格式.docx(103页珍藏版)》请在冰豆网上搜索。
![java蓝宇快递打印系统文档格式.docx](https://file1.bdocx.com/fileroot1/2022-11/20/b80ba4d4-4c4a-42dd-88d3-923d8291d3f9/b80ba4d4-4c4a-42dd-88d3-923d8291d3f91.gif)
并将其保存在数据库中以便以后查看。
通过以上对快递系统的了解,要求其具备如下功能:
(1)具有安全可靠的登陆系统。
(2)能够添加快递单信息。
(3)可以修改快递单信息。
(4)可以打印快递单信息。
(5)进入系统后,可以通过“添加用户”功能添加新的用户信息。
(6)能修改密码,提高系统的安全性。
二总体设计
通过对系统进行深入的分析得知,本系统需要实现以下目标:
(1)操作简单方便,界面整洁大方。
(2)保证系统的安全性。
(3)方便添加和修改快递信息。
(4)完成快递单的打印功能。
(5)支持用户添加和密码修改操作。
操作系统:
Windows7旗舰版
JDK版本:
jdk-7u3-windows-i586
IDE版本:
IndigoServiceRelease2
开发语言:
Java
后台数据库:
SQLServer2005
分辨率:
最佳效果1024×
768像素
在需求分析的基础上,确定了该系统需要实现的功能。
根据功能设计出该系统的功能结构图,如下图所示。
三数据库设计
本系统采用SQLServer2005作为后台数据库。
根据需求分析和功能结构图,为整个系统设计了两个数据表,分别用于存储快递单信息和用户信息。
根据这两个表的存储信息和功能,分别设计对应的E-R图和数据表。
快递单信息表tb_receiveSendMessage的E-R图,如左图所示。
用户信息表tb_user的E-R图,如右图所示。
四公共类设计
(1)公共类DAO,用于加载数据库驱动及建立数据库连接。
具体设计如下:
packagecom.zzk.dao;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjavax.swing.JOptionPane;
publicclassDAO{
privatestaticDAOdao=newDAO();
//声明DAO类的静态实例
/**
*构造方法,加载数据库驱动
*/
publicDAO(){
try{
Class.forName("
net.sourceforge.jtds.jdbc.Driver"
);
//加载数据库驱动
}catch(ClassNotFoundExceptione){
JOptionPane.showMessageDialog(null,"
数据库驱动加载失败,请将JTDS驱动配置到构建路径中。
\n"
+e.getMessage());
}
*获得数据库连接的方法
*
*@returnConnection
publicstaticConnectiongetConn(){
Connectionconn=null;
//定义数据库连接
Stringurl="
jdbc:
jtds:
sqlserver:
//localhost:
1433/db_ExpressPrint"
;
//数据库db_Express的URL
Stringusername="
sa"
//数据库的用户名
Stringpassword="
"
//数据库密码
conn=DriverManager.getConnection(url,username,password);
//建立连接
returnconn;
//返回连接
}catch(Exceptione){
数据库连接失败。
\n请检查数据库用户名和密码是否正确。
returnnull;
}
(2)公共类SaveUserStateTool,用于保存登录用户的用户名和密码。
该类主要用于修改用户的密码。
具体实现如下:
packagecom.zzk.tool;
publicclassSaveUserStateTool{
privatestaticStringusername=null;
privatestaticStringpassword=null;
publicstaticvoidsetUsername(Stringusername){
SaveUserStateTool.username=username;
publicstaticStringgetUsername(){
returnusername;
publicstaticvoidsetPassword(Stringpassword){
SaveUserStateTool.password=password;
publicstaticStringgetPassword(){
returnpassword;
五程序主要系统开发
1.系统登录系统设计
(1)用于封装用户输入的登录信息的User设计:
(2)用于封装用户名和密码进行验证的UserDao类设计:
2.系统主界面系统设计
3.添加快递信息系统设计
4.修改快递信息系统设计
5.打印快递单与打印设置系统设计
6.添加用户窗体系统设计
7.修改用户密码窗体系统设计
六调试与测试实验结果
(附注:
用户使用说明及实验结果如下:
)
(1)程序说明
本程序使用SQLServer2005数据库开发,导入项目以后需要再对数据库进行配置,配置完数据库运行项目启动文件src/com/zzk/frame/LoginFrame.java就可以运行程序了。
(2)操作流程
(1)启动程序以后,显示蓝宇快递打印系统登录界面,如图1所示:
图1登录界面
(2)输入用户、与密码之后,进入主界面,如图2所示,系统默认用户名mr,密码mrsoft。
(3)进入主界面可以对快递单进行各种操作,如图3所示:
七实验总结
通过本次综合实验,我进一步了解和掌握了Java中类的概念和定义,继承和接口的概念和语法。
通过实验,我也进一步了解和掌握了Java中GUI的实现和用法以及数据库等基本操作。
当然,在实验的过程中,也遇到了很多问题,但在老师和同学的帮助和指导下终于解决了。
对于本次的打印系统综合实验,不仅使我认识到了自己在Java语言学习中的不足,而且增进了我对Java语言学习和编程的兴趣和能力。
也为后续Java的学习打下了一个良好的基础。
参考文献:
(1)《Java应用开发与实践》--刘乃琦苏畅主编。
(2)《Java从初学到精通》--辛立伟张帆编著
附录(源代码如下:
)
package快递打印系统;
importjava.awt.*;
importjavax.swing.*;
importjavax.swing.SwingUtilities;
importjavax.swing.WindowConstants;
importjavax.swing.ImageIcon;
import.URL;
importjava.awt.FlowLayout;
importjava.awt.print.PageFormat;
importjava.awt.print.Printable;
importjava.awt.print.PrinterJob;
importjava.util.Vector;
importjava.awt.Graphics;
importjava.util.Arrays;
importjava.sql.*;
importjava.sql.SQLException;
//////////////////////////////////////
classUser{
privateStringname=null;
privateStringpwd=null;
privateStringokPwd=null;
publicStringgetName(){
returnname;
publicvoidsetName(Stringname){
this.name=name;
publicStringgetPwd(){
returnpwd;
publicvoidsetPwd(Stringpwd){
this.pwd=pwd;
publicvoidsetOkPwd(StringokPwd){
this.okPwd=okPwd;
publicStringgetOkPwd(){
returnokPwd;
classExpressMessage{
privateintid=0;
privateStringsendName=null;
privateStringsendTelephone=null;
privateStringsendCompary=null;
privateStringsendAddress=null;
privateStringsendPostcode=null;
privateStringreceiveName=null;
privateStringreceiveTelephone=null;
privateStringreceiveCompary=null;
privateStringreceiveAddress=null;
privateStringreceivePostcode=null;
privateStringControlPosition=null;
//快递单上添加信息的组件位置(坐标)
privateStringexpressSize=null;
//快递单的尺寸(大小)
publicintgetId(){
returnid;
publicvoidsetId(intid){
this.id=id;
publicStringgetSendName(){
returnsendName;
publicvoidsetSendName(StringsendName){
this.sendName=sendName;
publicStringgetSendTelephone(){
returnsendTelephone;
publicvoidsetSendTelephone(StringsendTelephone){
this.sendTelephone=sendTelephone;
publicStringgetSendCompary(){
returnsendCompary;
publicvoidsetSendCompary(StringsendCompary){
this.sendCompary=sendCompary;
publicStringgetSendAddress(){
returnsendAddress;
publicvoidsetSendAddress(StringsendAddress){
this.sendAddress=sendAddress;
publicStringgetSendPostcode(){
returnsendPostcode;
publicvoidsetSendPostcode(StringsendPostcode){
this.sendPostcode=sendPostcode;
publicStringgetReceiveName(){
returnreceiveName;
publicvoidsetReceiveName(StringreceiveName){
this.receiveName=receiveName;
publicStringgetReceiveTelephone(){
returnreceiveTelephone;
publicvoidsetReceiveTelephone(StringrecieveTelephone){
this.receiveTelephone=recieveTelephone;
publicStringgetReceiveCompary(){
returnreceiveCompary;
publicvoidsetReceiveCompary(StringrecieveCompary){
this.receiveCompary=recieveCompary;
publicStringgetReceiveAddress(){
returnreceiveAddress;
publicvoidsetReceiveAddress(StringreceiveAddress){
this.receiveAddress=receiveAddress;
publicStringgetReceivePostcode(){
returnreceivePostcode;
publicvoidsetReceivePostcode(StringreceivePostcode){
this.receivePostcode=receivePostcode;
publicStringgetControlPosition(){
returnControlPosition;
publicvoidsetControlPosition(StringcontrolPosition){
ControlPosition=controlPosition;
publicStringgetExpressSize(){
returnexpressSize;
publicvoidsetExpressSize(StringexpressSize){
this.expressSize=expressSize;
classExpressMessageDao{
publicstaticvoidinsertExpress(ExpressMessagem){
if(m.getSendName()==null||m.getSendName().trim().equals("
)){
寄件人信息必须填写。
return;
if(m.getSendTelephone()==null||m.getSendTelephone().trim().equals("
if(m.getSendCompary()==null||m.getSendCompary().trim().equals("
if(m.getSendAddress()==null||m.getSendAddress().trim().equals("
||"
if(m.getSendPostcode()==null||m.getSendPostcode().trim().equals("
if(m.getReceiveName()==null||m.getReceiveName().trim().equals("
收件人信息必须填写。
if(m.getReceiveTelephone()==null||m.getReceiveTelephone().trim().equals("
if(m.getReceiveCompary()==null||m.getReceiveCompary().trim().equals("
if(m.getReceiveAddress()==null||m.getReceiveAddress().trim().equals("
if(m.getReceivePostcode()==null||m.getReceivePostcode().trim().equals("
//声明数据库连接
//声明PreparedStatement对象
PreparedStatementps=null;
conn=DAO.getConn();
//获得数据库连接
//创建PreparedStatement对象,并传递SQL语句
ps=conn
.prepareStatement("
insertintotb_receiveSendMessage(sendName,sendTelephone,sendCompary,sendAddress,sendPostcode,receiveName,recieveTelephone,recieveCompary,receiveAddress,receivePostcode,ControlPosition,expressSize)values(?
?
)"
ps.setString(1,m.getSendName());
//为参数赋值
ps.setString(2,m.getSendTelephone());
ps.setString(3,m.getSendCompary());
ps.setString(4,m.getSendAddress());
ps.setString(5,m.getSendPostcode());
ps.setString(6,m.getReceiveName());
ps.setString(7,m.getReceiveTelephone());
ps.setString(8,m.getReceiveCompary());
ps.setString(9,m.getReceiveAddress());
ps.setString(10,m.getReceivePostcode());
ps.setString(11,m.getControlPosition());
ps.setString(12,m.getExpressSize());
intflag=ps.executeUpdate();
if(flag>
0){
添加成功。
}else{
添加失败。
}catch(Exceptionex){
JOpti