📄 dailypperationsystempanel.java
字号:
}
else
{
sql = "select TypeID from BooksType where typeName='" +
clickNode.toString().trim() + "'";
db.search(sql);
try {
if (db.rs.next())
bti = db.rs.getString(1).trim();
} catch (SQLException ex) {
System.out.println(ex.toString());
return;
}
db.myClose(1);
}
sql = "select * from booksInfo where bookTypeID like'"+bti.trim()+"'+'%'";
typeTemp=clickNode.toString().trim();
try
{
//查询方法方法
rs = db.booksInfosearch(sql);
int count=0;
while(rs.next())
count++;
rs.first();
data = new String[count][title_size];
for(int i=0;i<count;i++)
{
for(int j=0;j<title_size;j++)
{
data[i][j] = rs.getString(j+2).trim();
}
rs.next();
}
DefaultTableModel model = new DefaultTableModel(data,title);
jTabRightTop.setModel(model);
jTabRightTop.updateUI();
db.myClose(1);
// }else
// JOptionPane.showMessageDialog(this, "连接数据库失败", "连接错误", JOptionPane.WARNING_MESSAGE);
}
catch(SQLException sex)
{
System.out.println(sex.toString());
// sex.printStackTrace();
}
}
}
public void jScright_ancestorResized(HierarchyEvent e) {
jPanRight.setSize((jScright.getWidth()-1),(jScright.getHeight()-1));
}
public void jScright_componentResized(ComponentEvent e) {
jPanRight.setSize((jSpSystemPanel.getWidth()- jScleft.getWidth()),(jSpSystemPanel.getHeight()-1));
}
public void jPaneRightBottom_componentResized(ComponentEvent e) {
jTpRightBottom.setSize(jPaneRightBottom.getWidth()-1,jPaneRightBottom.getHeight()-1);
}
public void jSpSystemPanel_componentResized(ComponentEvent e) {
jPanRight.setSize((jSpSystemPanel.getWidth()- jScleft.getWidth()),(jSpSystemPanel.getHeight()-1));
}
public void jTreBooks_mouseClicked(MouseEvent e) {
display();
}
public void jTabRightTop_mouseClicked(MouseEvent e) {
if(e.getButton()==e.BUTTON1)
{
/*
jTxbookNum.setText("");
jTxbookAuthor.setText("");
jTxbookConcern.setText("");
jTxpurchaseMoney.setText("");
*/
//表的行从0开始编号
//JOptionPane.showMessageDialog(null,""+jTabRightTop.getSelectedRow());
//获取书名
String name=jTabRightTop.getValueAt(jTabRightTop.getSelectedRow(),0).toString();
jTxbookName.setText(name);
jtxbooksNameG.setText(name);
jtxbooksNamex.setText(name);
jtxbooksNamexD.setText(name);
//获取书的编号
String bokksNum = jTabRightTop.getValueAt(jTabRightTop.getSelectedRow(),1).toString();
jTxbookNum.setText(bokksNum);
jTxbookNumD.setText(bokksNum);
jtxbooksNumX.setText(bokksNum);
jTxbookNumG.setText(bokksNum);
//获取书的作者
String author = jTabRightTop.getValueAt(jTabRightTop.getSelectedRow(),3).toString();
jTxbookAuthor.setText(author);
jTxbookAuthorD.setText(author);
jTxbookAuthorG.setText(author);
jTxbookAuthorX.setText(author);
//获取出版社
String concern = jTabRightTop.getValueAt(jTabRightTop.getSelectedRow(),4).toString();
jTxbookConcern.setText(concern);
jTxbookConcernD.setText(concern);
jTxbookConcernG.setText(concern);
jTxbookConcernX.setText(concern);
//获取定价
String money = jTabRightTop.getValueAt(jTabRightTop.getSelectedRow(),6).toString();
jTxpurchaseMoney.setText(money);
jTxpurchaseMoneyD.setText(money);
jTxpurchaseMoneyG.setText(money);
jTxpurchaseMoneyX.setText(money);
//获取书的类型
jTxbookType.setText(typeTemp);
jTxbookTypeD.setText(typeTemp);
jTxbookTypeG.setText(typeTemp);
jtxbookTypeX.setText(typeTemp);
}
}
public void btnReset_actionPerformed(ActionEvent e) {
jTxbookNum.setText("");
jTxbookAuthor.setText("");
jTxbookConcern.setText("");
jTxpurchaseMoney.setText("");
jTxbookName.setText("");
jTxbookType.setText("");
jTxreaderNum.setText("");
jTxNumber.setText("点击查询当前读者的借书数量");
}
public void jTxNumber_mouseClicked(MouseEvent e) {
//查询读者的借书数量
borrowBooksNum();
}
public void jPanRight_componentResized(ComponentEvent e) {
jPanelRightTop.setSize((jPanRight.getWidth()-1),
(jPanRight.getHeight()) / 2-3);
jScrollPane1.setSize((jPanelRightTop.getWidth()),jPanelRightTop.getHeight());
// jSpSystemPanel.setDividerLocation(0.21);
jPaneRightBottom.setBounds(jPanRight.getX(),jPanRight.getHeight()/2-1,(jPanRight.getWidth()-1),
(jPanRight.getHeight()) / 2-1);
}
public void this_componentResized(ComponentEvent e) {
jSpSystemPanel.setSize( (this.getWidth())-5,(this.getHeight()-30));
jSpSystemPanel.setDividerLocation(0.26);
jPanRight.setSize((jSpSystemPanel.getWidth()- jScleft.getWidth()),(jSpSystemPanel.getHeight()-1));
}
public void this_ancestorResized(HierarchyEvent e) {
jSpSystemPanel.setSize( (this.getWidth())-5,(this.getHeight()-30));
jSpSystemPanel.setDividerLocation(0.26);
jPanRight.setSize((jSpSystemPanel.getWidth()- jScleft.getWidth()),(jSpSystemPanel.getHeight()-1));
jPanelSystemTop.setSize(this.getWidth()-5,30);
}
public void jTxReaderNumG_mouseClicked(MouseEvent e) {
inputReaderNum();
}
public void inputReaderNum()
{
String bianhao="";
try {
bianhao= JOptionPane.showInputDialog(null,"请输入读者编号 例如 ","A0000001").trim();
} catch (Exception ex) {
// JOptionPane.showMessageDialog(null, "你没有输入读者信息");
}
if(!bianhao.equals("")){
if ((int)bianhao.charAt(0)>='A' && (int)bianhao.charAt(0) <= 'Z' ) {
jTxReaderNumD.setText(bianhao);
jTxReaderNumG.setText(bianhao);
jTxReaderNumX.setText(bianhao);
jTxreaderNum.setText(bianhao);
borrowBooksNum();
}
}
}
public void jTxreaderNum_mouseClicked(MouseEvent e) {
inputReaderNum();
}
public void jTxReaderNumX_mouseClicked(MouseEvent e) {
inputReaderNum();
}
public void jTxReaderNumD_mouseClicked(MouseEvent e) {
inputReaderNum();
}
public void btnQueren_actionPerformed(ActionEvent e) {
borrowBooks();
}
//借书方法
public void borrowBooks()
{
String booksNum = jTxbookNum.getText().trim();
String readerNum = jTxreaderNum.getText().trim();
if(booksNum.trim().equals(""))
JOptionPane.showMessageDialog(null,"图书信息不能为空");
else if(readerNum.trim().equals(""))
JOptionPane.showMessageDialog(null,"读者信息不能为空");
else if(!isReader)
JOptionPane.showMessageDialog(null,"此读者不存在,请核对借阅证!!!","错误",JOptionPane.ERROR_MESSAGE);
else if(readerNumTempMax > readerNumTemp)
{
String sqlbook =
"update booksInfo set borrowMoneyNum=borrowMoneyNum-1 where booksNum='" +
booksNum + "' and borrowMoneyNum > 0";
String sqlreader =
"update readerInfo set state = 1,borrowBooksNum = borrowBooksNum+1 where readerID='" +readerNum + "' and zhuangtai=1" ;
if (db.add(sqlbook)) {
db.myClose(1);
if(db.add(sqlreader)){
db.myClose(1);
String sql =
"insert into booksBoorowInfo (bookId,readerId,beginTime,borrowHandlers) values ('" +
booksNum + "','" + readerNum + "','" +SystemFrame1.dateTime + "','"+SystemFrame1.login+"')";
if (db.add(sql)) {
JOptionPane.showMessageDialog(null, "借书成功");
borrowBooksNum();
display();
} else {
JOptionPane.showMessageDialog(null, "借书失败", "失败",
JOptionPane.ERROR_MESSAGE);
}
db.myClose(1);
}
}
else
JOptionPane.showMessageDialog(null, "此本书已经全部借出\n借阅失败","失败",JOptionPane.ERROR_MESSAGE);
}else
JOptionPane.showMessageDialog(null, "你的借书数量已经达到上限,请先归还","警告",JOptionPane.WARNING_MESSAGE);
}
//还书方法
public void returnBooks()
{
String booksNum = jTxbookNumG.getText().trim();
String readerNum = jTxReaderNumG.getText().trim();
if(booksNum.trim().equals(""))
JOptionPane.showMessageDialog(null,"图书信息不能为空");
else if(readerNum.trim().equals(""))
JOptionPane.showMessageDialog(null,"读者信息不能为空");
else if(!isReader)
JOptionPane.showMessageDialog(null,"此读者不存在,请核对借阅证!!!","错误",JOptionPane.ERROR_MESSAGE);
else if( readerNumTemp>0)
{
String sqlbook =
"update booksInfo set borrowMoneyNum=borrowMoneyNum+1 where booksNum='" +
booksNum + "'";
String sqlreader ="update readerInfo set borrowBooksNum = borrowBooksNum-1 where readerID='" +readerNum + "'" ;
String sqlreader2 ="update readerInfo set state = 0 where readerID='" +readerNum + "'and borrowBooksNum=0" ;
if (db.add(sqlbook)) {
db.myClose(1);
if(db.add(sqlreader)){
db.myClose(1);
String sql =
"update booksBoorowInfo set returnTime='"+SystemFrame1.dateTime+"',returnHandlers='"+SystemFrame1.login+"' ,isreturnbook = '是' where bookId='"+booksNum+"'";
if (db.add(sql)) {
db.myClose(1);
db.add(sqlreader2);
db.myClose(1);
JOptionPane.showMessageDialog(null, "还书成功");
borrowBooksNum();
display();
} else {
JOptionPane.showMessageDialog(null, "还书失败", "失败",
JOptionPane.ERROR_MESSAGE);
}
}
}
}else
JOptionPane.showMessageDialog(null, "你已经归还全部的图书","警告",JOptionPane.WARNING_MESSAGE);
}
public void jTxNumberX_mouseClicked(MouseEvent e) {
borrowBooksNum();
}
//点击查询读者的借书数量
public void borrowBooksNum()
{
String bianhao= jTxreaderNum.getText().trim();
String num = "";
String readerTypeNameTemp = "";
if((int)bianhao.charAt(0)>='A' && (int)bianhao.charAt(0) <= 'Z' )
{
Dbcom readerDB = new Dbcom();
ResultSet rs = null;
//查询读者的借书数量
String sql = "select borrowBooksNum,readerTypeName from readerInfo where readerID='"+bianhao+"'";
rs = readerDB.search(sql);
try {
if(rs.next()){
num = rs.getString(1);
if (num == null)
num = "0";
readerTypeNameTemp = rs.getString(2);
jTxNumberD.setText(num);
jTxNumberG.setText(num);
jTxNumberX.setText(num);
jTxNumber.setText(num);
readerNumTemp = Integer.parseInt(num);
isReader = true;
}
else
JOptionPane.showMessageDialog(null,"此读者不存在,请核对借阅证!!!","错误",JOptionPane.ERROR_MESSAGE);
readerDB.myClose(1);
} catch (SQLException ex) {
System.out.println(ex.toString());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -