}
public String getPh() { returnthis.ph; }
publicvoid setPh(String ph) { this.ph = ph; }
public String getPzwh() { returnthis.pzwh; }
publicvoid setPzwh(String pzwh) { this.pzwh = pzwh; }
public String getMemo() { returnthis.memo; }
publicvoid setMemo(String memo) { this.memo = memo; }
public String getGysname() { returnthis.gysname; }
publicvoid setGysname(String gysname) { this.gysname = gysname; }
public String toString() { return getSpname(); }
@Override
publicint hashCode() { finalintPRIME = 31; intresult = 1;
result = PRIME * result + ((bz == null) ? 0 : bz.hashCode()); result = PRIME * result + ((cd == null) ? 0 : cd.hashCode());
result = PRIME * result + ((dw == null) ? 0 : dw.hashCode()); result = PRIME * result + ((gg == null) ? 0 : gg.hashCode()); result = PRIME * result + ((gysname == null) ? 0 : gysname.hashCode());
result = PRIME * result + ((id == null) ? 0 : id.hashCode()); result = PRIME * result + ((jc == null) ? 0 : jc.hashCode()); result = PRIME * result + ((memo == null) ? 0 : memo.hashCode());
result = PRIME * result + ((ph == null) ? 0 : ph.hashCode()); result = PRIME * result + ((pzwh == null) ? 0 : pzwh.hashCode());
result = PRIME * result + ((spname == null) ? 0 : spname.hashCode()); returnresult; }
@Override
publicboolean equals(Object obj) { if (this == obj) returntrue; if (obj == null) returnfalse;
if (getClass() != obj.getClass()) returnfalse;
final TbSpinfo other = (TbSpinfo) obj; if (bz == null) {
if (other.bz != null) returnfalse;
} elseif (!bz.equals(other.bz)) returnfalse; if (cd == null) {
if (other.cd != null) returnfalse;
} elseif (!cd.equals(other.cd)) returnfalse; if (dw == null) {
if (other.dw != null) returnfalse;
} elseif (!dw.equals(other.dw)) returnfalse; if (gg == null) {
if (other.gg != null) returnfalse;
} elseif (!gg.equals(other.gg))
}
}
returnfalse;
if (gysname == null) {
if (other.gysname != null) returnfalse;
} elseif (!gysname.equals(other.gysname)) returnfalse; if (id == null) {
if (other.id != null) returnfalse;
} elseif (!id.equals(other.id)) returnfalse; if (jc == null) {
if (other.jc != null) returnfalse;
} elseif (!jc.equals(other.jc)) returnfalse;
if (memo == null) {
if (other.memo != null) returnfalse;
} elseif (!memo.equals(other.memo)) returnfalse; if (ph == null) {
if (other.ph != null) returnfalse;
} elseif (!ph.equals(other.ph)) returnfalse;
if (pzwh == null) {
if (other.pzwh != null) returnfalse;
} elseif (!pzwh.equals(other.pzwh)) returnfalse;
if (spname == null) {
if (other.spname != null) returnfalse;
} elseif (!spname.equals(other.spname)) returnfalse; returntrue;
3.Dao公共类
Dao的全称是Data Access Object,即数据访问对象。本项目中应用该名称作为数据库访问类的名称,在该类中实现了数据库的驱动、连接、关闭和多个操作数据库的方法,这些方法包括不同数据表的操作方法。在介绍具体的数据库访问方
法之前,先来看一下Dao类的定义,也就是数据库驱动和连接的代码。 代码如下
publicclass Dao {
static Statement sql; static ResultSet res;
protectedstatic String dbClassName=\; protectedstatic String
dbUrl=\; protectedstatic String dbUser=\;
protectedstatic String dbPwd=\; protectedstatic String second = null;
publicstatic Connection conn=null;
static{ try{
if(conn==null){
Class.forName(dbClassName).newInstance(); conn = (Connection)
DriverManager.getConnection(dbUrl,dbUser,dbPwd); }
}catch(Exception ee){ ee.printStackTrace();
} }
3.4系统登录模块设计 1.设计登录窗体
登录模块的窗体设计由两部分组成,一部分是登录窗体,另一部分是窗体中带背景图片的内容面板。
1.创建内容面板
publicclassLoginPanelextends JPanel { publicintwidth, height; private Image img; public LoginPanel() { super();
URL url = getClass().getResource(\); img = new ImageIcon(url).getImage(); }
protectedvoid paintComponent(Graphics g) { super.paintComponent(g);
g.drawImage(img, 0, 0, this); } }
2.创建登录窗体
private LoginPanel getLoginPanel() { if (loginPanel == null) { jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(86, 71, 55, 18)); jLabel1.setText(\密 码:\); jLabel = new JLabel();
jLabel.setText(\用户名:\);
jLabel.setBounds(new Rectangle(85, 41, 56, 18)); loginPanel = new LoginPanel(); loginPanel.setLayout(null);
loginPanel.setBackground(new Color(0xD8DDC7)); loginPanel.add(jLabel, null);
loginPanel.add(getUserField(), null); loginPanel.add(jLabel1, null);