import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Label;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRootPane;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.omg.PortableServer.THREAD_POLICY_ID;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
public class MemberInfo extends Thread {
private String teleNo;
private JFrame f;
public boolean closeType = false;
/**
* 构造方法
* @param teleNo
*/
public MemberInfo(String teleNo) {
this.teleNo = teleNo;
}
/**
* 通过xml获取数据库连接池
* 张超
*2012Sep 11, 2012
*/
public Connection dealDBXml() {
String driverName = null;
String username = null;
String userPasswd = null;
String dbName = null;
String dbUrl = null;
Connection conn = null;
try {
File f = new File("../xml/db.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(f);
NodeList nl = doc.getElementsByTagName("value");
for (int i = 0; i < nl.getLength(); i++) {
driverName = doc.getElementsByTagName("driverName").item(i)
.getFirstChild().getNodeValue();
username = doc.getElementsByTagName("username").item(i)
.getFirstChild().getNodeValue();
userPasswd = doc.getElementsByTagName("userPasswd").item(i)
.getFirstChild().getNodeValue();
dbName = doc.getElementsByTagName("dbName").item(i)
.getFirstChild().getNodeValue();
dbUrl = doc.getElementsByTagName("dbUrl").item(i)
.getFirstChild().getNodeValue();
}
String url = dbUrl
+ dbName
+ "?user="
+ username
+ "&password="
+ userPasswd
+ "&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8";
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = (Connection) DriverManager.getConnection(url);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
return conn;
}
}
/**
* 通过数据库获取会员信息
* 张超
*2012Sep 11, 2012
*/
@SuppressWarnings("unchecked")
public Map<String,String> getMemberInfor(String teleNo) {
Connection conn = this.dealDBXml();
Statement statement = null;
HashMap<String,String> map = new HashMap();
String sql2 = "select count(*) from member m where m.companyTelephoe=" + teleNo
+ " or m.mobileNumber=" + teleNo;
String sql = "select * from member m where m.companyTelephoe=" + teleNo
+ " or m.mobileNumber=" + teleNo;
try {
Statement statement2 = conn.createStatement();
ResultSet rs2 = statement2.executeQuery(sql2);
while(rs2.next()) {
int count = rs2.getInt(1);
if(count == 1) {
statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
String userCode = rs.getString("userCode");
String userPassword = rs.getString("userPassword");
String userName = rs.getString("userName");
String companyAddress = rs.getString("companyAddress");
String scoreRemain = rs.getString("scoreRemain");
String scoreUsed = rs.getString("scoreUsed");
map.put("userCode", userCode);
map.put("userPassword", userPassword);
map.put("userName", userName);
map.put("companyAddress", companyAddress);
map.put("scoreRemain", scoreRemain);
map.put("scoreUsed", scoreUsed);
}
rs.close();
statement.close();
} else {
map.put("userCode", "");
map.put("userPassword", "");
map.put("userName", "");
map.put("companyAddress", "");
map.put("scoreRemain", "");
map.put("scoreUsed", "");
}
}
rs2.close();
statement2.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return map;
}
public void viewMemberInfo(String teleNo) {
this.f = new JFrame("会员信息");
f.setSize(400, 200);
f.setLocation(1000, 700);
f.getRootPane().setWindowDecorationStyle(JRootPane.INFORMATION_DIALOG); // 设置为简单对话框风格
f.setUndecorated(true); // 去掉窗口的装饰
Map<String, String> map = this.getMemberInfor(teleNo);
String userCode = map.get("userCode");
String userPassword = map.get("userPassword");
String userName = map.get("userName");
String companyAddress = map.get("companyAddress");
String scoreRemain = map.get("scoreRemain");
String scoreUsed = map.get("scoreUsed");
JLabel b1 = new JLabel();
b1.setText("会员名称:");
JLabel b2 = new JLabel();
b2.setText(" "+userName);
JLabel b3 = new JLabel();
b3.setText("会员卡号:");
JLabel b4 = new JLabel();
b4.setText(" "+userCode);
JLabel b5 = new JLabel();
b5.setText("会员密码:");
JLabel b6 = new JLabel();
b6.setText(" "+userPassword);
JLabel b7 = new JLabel();
b7.setText("公司地址:");
JLabel b8 = new JLabel();
b8.setText(" "+companyAddress);
JLabel b9 = new JLabel();
b9.setText("剩余积分:");
JLabel b10 = new JLabel();
b10.setText(" "+scoreRemain);
JLabel b11 = new JLabel();
b11.setText("已用积分:");
JLabel b12 = new JLabel();
b12.setText(" "+scoreUsed);
JLabel b13 = new JLabel();
b13.setText("来电显示:");
JLabel b14 = new JLabel();
b14.setText(" "+teleNo);
GridBagConstraints c = new GridBagConstraints();
GridBagLayout g = new GridBagLayout();
f.setLayout(g);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(b1); //由于属性都有默认值,前面的按默认值来加入!
f.add(b2);
c.gridy = 1;
c.fill = GridBagConstraints.BOTH; //所以这里要做相应的修改才能按gridwidth的值来显示
g.setConstraints(b3, c);
f.add(b3);
c = new GridBagConstraints();
c.gridy = 1;
g.setConstraints(b4, c);
f.add(b4);
c = new GridBagConstraints();
c.gridy = 2;
g.setConstraints(b5, c);
f.add(b5);
c = new GridBagConstraints();
c.gridy = 2;
g.setConstraints(b6, c);
f.add(b6);
c = new GridBagConstraints();
c.gridy = 3;
g.setConstraints(b7, c);
f.add(b7);
c = new GridBagConstraints();
c.gridy = 3;
g.setConstraints(b8, c);
f.add(b8);
c = new GridBagConstraints();
c.gridy = 4;
g.setConstraints(b9, c);
f.add(b9);
c = new GridBagConstraints();
c.gridy = 4;
g.setConstraints(b10, c);
f.add(b10);
c = new GridBagConstraints();
c.gridy = 5;
g.setConstraints(b11, c);
f.add(b11);
c = new GridBagConstraints();
c.gridy = 5;
g.setConstraints(b12, c);
f.add(b12);
c = new GridBagConstraints();
c.gridy = 6;
g.setConstraints(b13, c);
f.add(b13);
c = new GridBagConstraints();
c.gridy = 6;
g.setConstraints(b14, c);
f.add(b14);
/* f.addMouseListener(new MouseAdapter() {
//重写鼠标进入按键方法
public void mouseClicked(MouseEvent e) {
System.out.println("窗口被点击了");
closeType = false;
}
});*/
/*f.addMouseListener(new MouseAdapter() {
//重写鼠标进入按键方法
没有合适的资源?快使用搜索试试~ 我知道了~
通过fax modem 仪器获取座机电话来电显示功能
共28个文件
jar:11个
class:5个
java:3个
4星 · 超过85%的资源 需积分: 31 29 下载量 51 浏览量
2012-09-12
14:31:00
上传
评论 1
收藏 6.1MB ZIP 举报
温馨提示
通过java代码获取usb fax modem获取座机来电显示内容,并弹出java窗口显示详情。
资源推荐
资源详情
资源评论
收起资源包目录
TELE.zip (28个子文件)
TELE
.project 380B
xml
db.xml 194B
src
MemberInfo.java 9KB
log4j.properties 950B
DealTeleMain.java 4KB
MobileInfo.java 2KB
lib
commons-codec-1.6.jar 227KB
htmlparser.jar 281KB
commons-httpclient-3.1.jar 298KB
commons-codec-1.6-tests.jar 210KB
commons-codec-1.6-javadoc.jar 349KB
commons-codec-1.6-sources.jar 238KB
comm.jar 27KB
ofbiz-entity.jar 3.68MB
smslib-3.3.0b2.jar 215KB
mysql-connector-java-5.0.8-bin.jar 528KB
log4j-1.2.11.jar 342KB
luoxin.log 0B
.settings
org.eclipse.core.runtime.prefs 83B
org.eclipse.core.resources.prefs 88B
.classpath 943B
bin
MobileInfo.class 3KB
MemberInfo.class 9KB
来电显示.bat 64B
log4j.properties 950B
DealTeleMain.class 4KB
MemberInfo$1.class 932B
MemberInfo$2.class 932B
共 28 条
- 1
资源评论
- wenh77882013-04-22我只能说这个对我没用用。有点坑。还我分数...
- newshine_sd2016-01-11可以用,参考一下。
- hsp212015-07-13不错,可用,谢谢楼主分型
- bmcsy2016-03-29感谢分享,相当受用。
fangniudewa
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功