package com.iotek.view;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import com.iotek.biz.DVDBiz;
import com.iotek.biz.impl.DVDBizImpl;
import com.iotek.entity.DVD;
import com.iotek.util.DVDUtil;
public class AdminDVDView extends JInternalFrame {
private static final long serialVersionUID = 1L;
//面板
private JPanel panelleft=null;//左边总面板
private JPanel paneltable=null;//保存table的面板
private JPanel panelButton=null;//保存按钮的面板
private JPanel panelDVD=null;//用于添加和更新DVD
//标签
private JLabel lb_type=null;
//添加dvd的信息框
private JLabel lb_dname=null;
private JLabel lb_dcount=null;
private JLabel lb_dtype=null;
//文本框
private JTextField tf_dname=null;
private JTextField tf_dcount=null;
private JTextField tf_content=null;
//表
private JTable table=null;
//按钮
private JButton btn_query=null;
private JButton btn_save=null;
private JButton btn_updata=null;
private JButton btn_del=null;
private JButton btn_exit=null;
//控件,可拉动
private JComboBox<String> cb_type=null;
private JComboBox<String> cb_dtype=null;
private DVDBiz dvdBiz=null;
private List<DVD> dvdList=null;
private DVDInfoTableModel infoTableModel=null;
public AdminDVDView() {
dvdBiz=new DVDBizImpl();
init();
registerListener();
}
private void init() {
this.setTitle("管理员DVD操作");
this.setSize(800,500);
this.setIconifiable(true);//窗体可最小化
this.setClosable(true);//可关闭
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
dvdList=new ArrayList<DVD>();
//左边
panelleft=new JPanel();
panelDVD=new JPanel(new GridLayout(1,6));
lb_dname=new JLabel("DVD名字");
lb_dcount=new JLabel("借出次数");
lb_dtype=new JLabel("DVD状态");
tf_dname=new JTextField();
tf_dcount=new JTextField();
cb_dtype=new JComboBox<String>(new String[] {
"已借","未借"
});
panelDVD.add(lb_dname);
panelDVD.add(tf_dname);
panelDVD.add(lb_dcount);
panelDVD.add(tf_dcount);
panelDVD.add(lb_dtype);
panelDVD.add(cb_dtype);
//初始化表
table =new JTable();
paneltable=new JPanel(new BorderLayout());//创建面板
//让Jtable绑定数据模型,得先初始化table,否则会造成空指针异常
refreshTable(dvdList);
//给面板设置边框
paneltable.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(null, null),"DVD记录查询"));
paneltable.add(table);
panelleft.add(paneltable, BorderLayout.CENTER);
panelleft.add(panelDVD,BorderLayout.SOUTH);
this.add(panelleft, BorderLayout.CENTER);
//初始化按键
lb_type=new JLabel("查询类型");
panelButton=new JPanel(new GridLayout(9, 1,10,20));
panelButton.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(null, null),"查询界面"));
this.add(panelButton, BorderLayout.EAST);
panelButton.add(lb_type);
cb_type=new JComboBox<String>(new String[] {""
+ "全部DVD","DVD编号","DVD名字"});
panelButton.add(cb_type);
//按键
tf_content=new JTextField();
tf_content.setEditable(false);
btn_query=new JButton("查询");
btn_save=new JButton("添加DVD");
btn_updata=new JButton("更新DVD");
btn_del=new JButton("删除DVD");
btn_exit=new JButton("退出");
//文本框加入
panelButton.add(tf_content);
//按键加入
panelButton.add(btn_query);
panelButton.add(btn_save);
panelButton.add(btn_updata);
panelButton.add(btn_del);
btn_updata.setEnabled(false);
btn_del.setEnabled(false);
panelButton.add(btn_exit);
this.setVisible(true);
}
private void registerListener() {
//给table注册鼠标监听事件
table.addMouseListener(new MouseAdapter() {
//鼠标点击事件
@Override
public void mouseClicked(MouseEvent e) {
//假设选择一行更新删除可用
if(table.getSelectedRow()!=-1) {
btn_updata.setEnabled(true);
btn_del.setEnabled(true);
}
int row=table.getSelectedRow();//得到选中哪行的下标
String dname=table.getValueAt(row, 1).toString();
String dcount=table.getValueAt(row, 2).toString();
String status=table.getValueAt(row, 3).toString();
tf_dname.setText(dname);
tf_dcount.setText(dcount);
cb_dtype.setSelectedItem(status);
}
});
//给下拉菜单注册选项事件监听器
cb_type.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
String item=e.getItem().toString();
tf_content.setText("");
if(item.equals("全部DVD")) {
tf_content.setEditable(false);
}else {
tf_content.setEditable(true);
}
}
});
//给添加按钮设置监听
btn_exit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int flag=JOptionPane.showInternalConfirmDialog(AdminDVDView.this,
"是否确定退出?", "确认信息", JOptionPane.YES_NO_OPTION);
if(flag==JOptionPane.YES_OPTION) {
AdminDVDView.this.dispose();
}
}
});
btn_del.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int row=table.getSelectedRow();
int did=(Integer)table.getValueAt(row, 0);
int flag=JOptionPane.showInternalConfirmDialog(AdminDVDView.this,
"是否删除?", "确认信息", JOptionPane.YES_NO_OPTION);
if(flag==JOptionPane.YES_OPTION) {
boolean res=dvdBiz.delDVD(did);
if(res) {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"删除成功!");
}else {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"删除失败");
}
}
}
});
btn_updata.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String dname=tf_dname.getText().trim();
String dcount=tf_dname.getText().trim();
int status=cb_dtype.getSelectedIndex();
if(dname.equals("")) {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"DVD名字不能为空");
return;
}
if(dcount.equals("")) {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"借出次数不能为空");
return;
}
if(!DVDUtil.isNumber(dcount)) {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"借出次数只能为数字");
return;
}
int flag=JOptionPane.showInternalConfirmDialog(AdminDVDView.this, ""
+ "是否确定更新?","确认信息",JOptionPane.YES_NO_OPTION);
if(flag==JOptionPane.YES_OPTION) {
int row=table.getSelectedColumn();
boolean res=dvdBiz.modifyDVD(new DVD((Integer)table.getValueAt(row, 0),
dname,dcount,status));
if(res) {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"更新成功");
}
else {
JOptionPane.showInternalMessageDialog(AdminDVDView.this,
"更新失败");
}
}
}
});
btn_save.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String dname=tf_dname.getText().trim();
String dcount=tf_dcount.getText().trim();
int status=cb_dtype.getSelectedIndex();//0代表已借1代表可借
if(dna
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA实战项目---DVD租赁管理系统
共98个文件
class:62个
java:27个
jpeg:2个
2星 需积分: 50 23 下载量 24 浏览量
2019-03-20
16:39:26
上传
评论 11
收藏 1.54MB ZIP 举报
温馨提示
Java项目,我用的是自己的mysql数据库,用户和密码都是自己的,所以如果要运行,自己修改一下,当然借鉴是完全可以的
资源推荐
资源详情
资源评论
收起资源包目录
test-DVD.zip (98个子文件)
test-DVD
.project 384B
src
lib
mysql-connector-java-5.0.8.jar 528KB
com
iotek
view
AdminMainView.java 4KB
211.jpg 11KB
2221.jpeg 214KB
AdminDVDView.java 12KB
UserRegisterView.java 4KB
AdminQueryRecordDVDView.java 6KB
UserQueryRecordDVDView.java 7KB
LoginView.java 4KB
UserQueryRentDVDView.java 7KB
UserMainView.java 4KB
dao
RecordDao.java 709B
UserDao.java 286B
impl
RecordDaoimpl.java 4KB
UserDaoImpl.java 2KB
DVDDaoimpl.java 3KB
BaseDao.java 3KB
DVDDao.java 562B
util
DVDUtil.java 258B
test
Test.java 354B
entity
User.java 928B
DVD.java 972B
Record2.java 1KB
Record.java 1KB
biz
RecordBiz.java 584B
impl
UserBizImpl.java 673B
DVDBizImpl.java 3KB
RecordBizImpl.java 1KB
UserBiz.java 206B
DVDBiz.java 660B
.settings
org.eclipse.jdt.core.prefs 598B
.classpath 378B
bin
lib
mysql-connector-java-5.0.8.jar 528KB
com
iotek
view
AdminQueryRecordDVDView$RcordInfoTableModel.class 3KB
UserQueryRentDVDView.class 5KB
AdminQueryRecordDVDView$2.class 1KB
UserMainView$DynaminThread.class 1KB
AdminDVDView$4.class 2KB
211.jpg 11KB
AdminDVDView$2.class 1KB
UserQueryRecordDVDView$UserInfoTableModel.class 3KB
UserMainView$3.class 1KB
UserQueryRecordDVDView$3.class 2KB
UserQueryRentDVDView$3.class 2KB
AdminMainView$DynaminThread.class 1KB
AdminDVDView.class 6KB
UserQueryRentDVDView$1.class 1KB
UserQueryRecordDVDView$4.class 1KB
UserQueryRecordDVDView.class 5KB
UserMainView$1.class 852B
2221.jpeg 214KB
AdminQueryRecordDVDView$1.class 2KB
UserMainView.class 5KB
UserQueryRentDVDView$2.class 2KB
AdminDVDView$1.class 2KB
AdminMainView.class 5KB
AdminMainView$3.class 1KB
LoginView$2.class 739B
AdminDVDView$6.class 2KB
AdminDVDView$3.class 993B
UserQueryRecordDVDView$1.class 1KB
UserQueryRecordDVDView$2.class 2KB
UserRegisterView.class 3KB
AdminMainView$4.class 743B
AdminMainView$2.class 1KB
AdminDVDView$DVDInfoTableModel.class 3KB
LoginView$1.class 2KB
LoginView.class 4KB
AdminMainView$1.class 861B
UserRegisterView$2.class 774B
AdminQueryRecordDVDView.class 4KB
AdminDVDView$7.class 3KB
UserMainView$4.class 737B
UserMainView$2.class 1KB
UserRegisterView$1.class 2KB
AdminDVDView$5.class 2KB
UserQueryRentDVDView$4.class 1KB
UserQueryRentDVDView$DVDInfoTableModel.class 3KB
dao
impl
UserDaoImpl.class 2KB
BaseDao.class 4KB
RecordDaoimpl.class 4KB
DVDDaoimpl.class 4KB
RecordDao.class 694B
DVDDao.class 700B
UserDao.class 274B
util
DVDUtil.class 612B
test
Test.class 430B
entity
User.class 1KB
Record2.class 2KB
Record.class 2KB
DVD.class 1KB
biz
DVDBiz.class 639B
RecordBiz.class 445B
impl
RecordBizImpl.class 2KB
UserBizImpl.class 931B
DVDBizImpl.class 3KB
UserBiz.class 228B
共 98 条
- 1
资源评论
- m0_664574912022-01-18没有数据库吗??? 老铁
- Beyond2019-04-16项目代码残缺不全根本没办法使用a13768711442019-12-13代码是没问题的,在你那执行有问题,那只能说明配置不同,思路是可以借鉴的,要运行也很简单照着代码配置一下,我不可能帮你把数据库的数据都给你一个一个打出来,放到你的数据库里吧
a1376871144
- 粉丝: 185
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功