赛迪网 > IT技术 Java > 技术动态
  IT资讯搜索
 
IT产品搜索
[程序开发][网管世界][网络安全][数据库技术]
[操作系统][嘉宾聊天·在线访谈][活动集锦]
[精彩专题][Symantec专区][订阅IT技术周刊]
[开发论坛][网管论坛][安全论坛][数据库论坛]
[操作系统论坛][Sybase专区][IBM dW技术专区]
[病毒求助][病毒与漏洞播报][文档·源码下载]

JAVA基础应用: 单机版管理系统源代码 (3)

发布时间:2007.03.29 01:36     来源:CN-JAVA    作者:jettang

//////////////////////////////////////////////////提交删除
if (e.getSource() == toolBarButton[6] ||
e.getSource() == subMenu2[6]) {
if ((classidT.getText().trim()).equals("") ||
(nameT.getText().trim()).equals("") ||
(sexT.getText().trim()).equals("") ||
(ageT.getText().trim()).equals("") ||
(callT.getText().trim()).equals("") ||
(departmentT.getText().trim()).equals("")) {
JOptionPane.showMessageDialog(null, "请先点击删除键");
return;
} else {
name = nameT.getText();
String strSQL = "delete from stuinfo where name='" + name +
"'";
try {
st.executeUpdate(strSQL);
} catch (Exception exx) {
JOptionPane.showMessageDialog(null, "删除失败");
return;
}
JOptionPane.showMessageDialog(null, "删除成功");
classidT.setText("");
nameT.setText("");
sexT.setText("");
ageT.setText("");
callT.setText("");
departmentT.setText("");

}
}

//////////////////////////////////////////////集体查询(按班级)
if (e.getSource() == subMenu3[0]) {
classidT.setText("");
nameT.setText("");
sexT.setText("");
ageT.setText("");
callT.setText("");
departmentT.setText("");

if ((classidT.getText().trim()).equals("")) {
String idclass = JOptionPane.showInputDialog("请输入班级");
String strSQL = "select * from stuinfo where classid='" +
idclass +
"'";
try {
rs = st.executeQuery(strSQL);
displayres(rs);

} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "查询失败");
}

} else {
String idclass = classidT.getText();
String strSQL = "select * from stuinfo where classid='" +
idclass +
"'";
try {
rs = st.executeQuery(strSQL);
displayres(rs);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "查询失败");
}
}
}
////////////////////////////按单位
if (e.getSource() == subMenu3[1]) {
classidT.setText("");
nameT.setText("");
sexT.setText("");
ageT.setText("");
callT.setText("");
departmentT.setText("");

if ((departmentT.getText().trim()).equals("")) {
String idclass = JOptionPane.showInputDialog("请输入单位");
String strSQL = "select * from stuinfo where department='" +
idclass +
"'";
try {
rs = st.executeQuery(strSQL);
displayres(rs);

} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "查询失败");
}

} else {
String idclass = departmentT.getText();
String strSQL = "select * from stuinfo where department='" +
idclass +
"'";
try {
rs = st.executeQuery(strSQL);
displayres(rs);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "查询失败");
}
}
}
}

public void displayres(ResultSet rs1) throws SQLException {
//定位到达第一条记录
boolean moreRecords = rs1.next();

//如果没有记录,则提示一条消息

if (!moreRecords) {

JOptionPane.showMessageDialog(null, "无此记录");

return;

}
try {

//获取数据
getNextRow(rs1);

//刷新Table
c.validate();

}

catch (SQLException sqlex) {

sqlex.printStackTrace();

}
}

public void getNextRow(ResultSet rs2) throws
SQLException {
int count = 1;
while (rs2.next()) {
name = " 姓名:" + rs2.getString(1);
age = " 年龄:" + rs2.getString(2) + " 单位:";
department = rs2.getString(3) + "\n";
textT.append(count + "." + name + age + department);
count++;
}
}
}

(t006)

<<上一页 1 2 3


[ 发表评论 ] 字体[  ] [ 打印 ] [ 进入博客 ] [ 进入论坛 ]  [ 推荐给朋友 ]
  相关文章
· 在无线J2ME设备上实现超文本传输协议 (03-28) · String和stringBuffer类字符串的区别 (03-27)
· 浅析Java语言中两种异常使用间的差别 (03-27) · JAVA基础应用:日期时间选择控件(代码) (03-27)
· 基于java的图片文件格式转换和线性缩放 (03-26) · JAVA基础:Javascript Cookie管理(程序) (03-26)
· JAVA基础应用: 处理Java中的日期问题 (03-26) · 教程:比较Java EE 5平台和J2EE 1.4平台 (03-26)
· JAVA基础应用: 如何实现希尔排序算法 (03-26) · JAVA应用: 浮点数转化为大写中文金额 (03-26)
  客户需求反馈表
* 姓  名:
更多资料  了解方案  认识厂商
* 单位名称:
* 联系电话:
* 电子邮件:
  赛迪推荐  
  手机·资费 ·新品·导购·评测·手机资费·宽带
手机搜索  诺基亚 N73 MOTO Z6
  IT产品 ·笔记本·台式机·服务器·打印·投影
IT产品搜索 
  IT技术 ·开发·网管·安全·数据库·操作系统
  信息化 ·热点·专题·访谈·周刊·方案案例
· 工信部“三定”公布 总编制731名设24司局
· 北京发电子商务监管意见 营利性网店须办照
· 直播 08中国城市信息化高峰论坛 案例点评
· 烽火网络校园解决方案 移民安置信息管理系统
  IT博客 ·曾剑秋·项立刚·Java学习·网管
  IT技术论坛 ·开发·网管·安全·数据库·系统