迁移成功
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.LoginFrm.LoginFrm">
|
||||
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="74" y="20" width="446" height="204"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="PingFang SC"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="1e979" binding="titlePanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4318d" class="javax.swing.JLabel" binding="titleLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="36" style="1"/>
|
||||
<text value="登录"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="a0f72" binding="bodyPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="40c81" binding="labelPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="a09bf" binding="uLabelPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="2">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="c9cc0" class="javax.swing.JLabel" binding="uLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="18" style="1"/>
|
||||
<text value="用户名:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="29291" binding="pLabelPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="2">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="dada" class="javax.swing.JLabel" binding="pLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="18" style="1"/>
|
||||
<horizontalAlignment value="10"/>
|
||||
<text value="密码:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="8481c" binding="fieldPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="4d39" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="fc448" class="javax.swing.JTextField" binding="uField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" style="1"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="f1071" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5fc4f" class="javax.swing.JPasswordField" binding="pField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" style="1"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="2e911" binding="bottomPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="fbf4e" class="javax.swing.JButton" binding="commitButton">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="18" style="1"/>
|
||||
<text value="登录"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.msksbr.LoginFrm;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.msksbr.MainFrm.MainFrm;
|
||||
import com.msksbr.SQL.Connector;
|
||||
import com.msksbr.images.EasterEgg;
|
||||
|
||||
public class LoginFrm extends JFrame {
|
||||
private final Connector connector;
|
||||
private final LoginMessangeExpection loginMessangeExpection;
|
||||
private JPanel panel1;
|
||||
private JPanel titlePanel;
|
||||
private JLabel titleLabel;
|
||||
private JPanel bodyPanel;
|
||||
private JPanel bottomPanel;
|
||||
private JButton commitButton;
|
||||
private JPanel labelPanel;
|
||||
private JPanel fieldPanel;
|
||||
private JPanel uLabelPanel;
|
||||
private JPanel pLabelPanel;
|
||||
private JLabel uLabel;
|
||||
private JLabel pLabel;
|
||||
private JTextField uField;
|
||||
private JPasswordField pField;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public LoginFrm() {
|
||||
loginMessangeExpection = new LoginMessangeExpection();
|
||||
setIconImage(new ImageIcon("src/com/msksbr/images/mainicon.png").getImage());
|
||||
try {
|
||||
connector = new Connector();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
setTitle("登录到图书管理系统");
|
||||
setContentPane(panel1);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
pack();
|
||||
setVisible(true);
|
||||
setSize(400, 250);
|
||||
setResizable(false);
|
||||
|
||||
Dimension fieldDimension = new Dimension(250, 30);
|
||||
this.uField.setPreferredSize(fieldDimension);
|
||||
this.pField.setPreferredSize(fieldDimension);
|
||||
|
||||
this.pField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
loginMessangeEntered();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.commitButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
this.commitButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
loginMessangeEntered();
|
||||
}
|
||||
});
|
||||
|
||||
setLocation();
|
||||
setDialogLocation();
|
||||
}
|
||||
|
||||
private void setLocation() {
|
||||
ScreenSize screenSize = new ScreenSize();
|
||||
setLocation(screenSize.width / 2 - getWidth() / 2, screenSize.height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
private void setDialogLocation() {
|
||||
loginMessangeExpection.setLocation(getX() + getWidth() / 4, getY() + getHeight() / 4);
|
||||
}
|
||||
|
||||
private void loginMessangeEntered() {
|
||||
username = uField.getText();
|
||||
password = new String(pField.getPassword());
|
||||
Boolean ISMessageTrue = isLoginMessageTrue();
|
||||
if (ISMessageTrue) {
|
||||
dispose();
|
||||
try {
|
||||
new MainFrm();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
loginMessangeExpection.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean isLoginMessageTrue() {
|
||||
if (username.equals("java") && password.equals("beans")) {
|
||||
new EasterEgg();
|
||||
return false;
|
||||
} else {
|
||||
try {
|
||||
ResultSet resultSet = connector.executeQuery("SELECT * FROM users WHERE username = '" + username + "'");
|
||||
if (resultSet != null && resultSet.next()) { // 检查结果集是否不为空
|
||||
if (resultSet.getString("password").equals(password)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.LoginFrm.LoginMessangeExpection">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="248" y="54" width="236" height="131"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="14" style="1"/>
|
||||
<text value="确认"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="42fcc" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="1.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="14" style="1"/>
|
||||
<text value="用户名或密码错误"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.msksbr.LoginFrm;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class LoginMessangeExpection extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
|
||||
public LoginMessangeExpection() {
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
setResizable(false);
|
||||
setSize(200, 150);
|
||||
|
||||
setTitle("登录失败");
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
onCancel();
|
||||
}
|
||||
});
|
||||
|
||||
// 点击 X 时调用 onCancel()
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
onCancel();
|
||||
}
|
||||
});
|
||||
|
||||
// 遇到 ESCAPE 时调用 onCancel()
|
||||
contentPane.registerKeyboardAction(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCancel();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
|
||||
private void onCancel() {
|
||||
// 必要时在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.msksbr.LoginFrm;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ScreenSize {
|
||||
public int width;
|
||||
public int height;
|
||||
public Dimension screenSize;
|
||||
|
||||
public ScreenSize() {
|
||||
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
width = screenSize.width;
|
||||
height = screenSize.height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: com.msksbr.Main.Main
|
||||
Class-Path: mysql-connector-j-8.4.0.jar flatlaf-3.2.jar
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.msksbr.Main;
|
||||
|
||||
import com.formdev.flatlaf.FlatDarculaLaf;
|
||||
|
||||
import com.msksbr.LoginFrm.LoginFrm;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
FlatDarculaLaf.install();
|
||||
new LoginFrm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MainFrm">
|
||||
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="742" height="409"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="3e1f8" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="a9381" binding="tablePanel" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="b90f2" class="javax.swing.JLabel" binding="backLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="4f963" binding="bottomPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="2">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.msksbr.MainFrm;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
import com.msksbr.SQL.Connector;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MainFrm extends JFrame {
|
||||
private Connector connector;
|
||||
private JPanel panel1;
|
||||
private JPanel tablePanel;
|
||||
private JPanel bottomPanel;
|
||||
private JLabel backLabel;
|
||||
private JLabel countMessage = new JLabel();
|
||||
private MenuBar menuBar;
|
||||
|
||||
public MainFrm() throws SQLException, ClassNotFoundException {
|
||||
setIconImage(new ImageIcon("src/com/msksbr/images/mainicon.png").getImage());
|
||||
connector = new Connector();
|
||||
setTitle("图书管理系统");
|
||||
setContentPane(panel1);
|
||||
pack();
|
||||
|
||||
menuBar = new MenuBar();
|
||||
|
||||
|
||||
setJMenuBar(menuBar);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setSize(960, 720);
|
||||
|
||||
String countData = "本馆共藏书" + getCount("books") + "本,共记录学生信息" + getCount("students") + "条,已借阅" + getCount("rents") + "本书,人均借阅" + (double) getCount("rents") / getCount("students") + "本";
|
||||
countMessage.setText(countData);
|
||||
bottomPanel.add(countMessage);
|
||||
ImageIcon imageIcon = new ImageIcon("src/com/msksbr/images/backGround.png");
|
||||
imageIcon.setImage(imageIcon.getImage().getScaledInstance(250, 250, 0));
|
||||
|
||||
backLabel.setIcon(imageIcon);
|
||||
|
||||
setMinimumSize(new Dimension(960, 720));
|
||||
|
||||
setLocation();
|
||||
initDialogs();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private void setLocation() {
|
||||
ScreenSize screenSize = new ScreenSize();
|
||||
setLocation(screenSize.width / 2 - getWidth() / 2, screenSize.height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
|
||||
private void initDialogs() {
|
||||
menuBar.exitItem.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private int getCount(String table) throws SQLException {
|
||||
ResultSet rs = connector.executeQuery("SELECT COUNT(*) AS bookCount FROM " + table + ";");
|
||||
rs.next();
|
||||
return rs.getInt("bookCount");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.msksbr.MainFrm;
|
||||
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.*;
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.Adder.BookAdder;
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.Adder.RentAdder;
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.Adder.StudentAdder;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class MenuBar extends JMenuBar {
|
||||
public JMenuItem exitItem;
|
||||
protected com.msksbr.MainFrm.MenuItemDiaog.aboutDIalog aboutDIalog;
|
||||
protected AuthorDIalog authorDIalog;
|
||||
|
||||
public MenuBar() {
|
||||
// “文件“菜单
|
||||
JMenu fileMenu = new JMenu("文件");
|
||||
exitItem = new JMenuItem("退出");
|
||||
fileMenu.add(exitItem);
|
||||
|
||||
// ”查询“菜单
|
||||
JMenu searchMenu = new JMenu("查询");
|
||||
JMenuItem bookSearch = new JMenuItem("查询图书信息");
|
||||
bookSearch.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SearchDIalog("books");
|
||||
}
|
||||
}
|
||||
);
|
||||
JMenuItem studentSearch = new JMenuItem("查询学生信息");
|
||||
studentSearch.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SearchDIalog("students");
|
||||
}
|
||||
});
|
||||
JMenuItem rentSearch = new JMenuItem("查询借阅信息");
|
||||
rentSearch.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SearchDIalog("rents");
|
||||
}
|
||||
});
|
||||
searchMenu.add(bookSearch);
|
||||
searchMenu.add(studentSearch);
|
||||
searchMenu.add(rentSearch);
|
||||
|
||||
// ”添加“菜单
|
||||
JMenu addMenu = new JMenu("添加");
|
||||
JMenuItem bookAdd = new JMenuItem("添加图书信息");
|
||||
bookAdd.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new BookAdder();
|
||||
}
|
||||
});
|
||||
JMenuItem studentAdd = new JMenuItem("添加学生信息");
|
||||
studentAdd.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new StudentAdder();
|
||||
}
|
||||
});
|
||||
JMenuItem rentAdd = new JMenuItem("添加借阅信息");
|
||||
rentAdd.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new RentAdder();
|
||||
}
|
||||
});
|
||||
addMenu.add(bookAdd);
|
||||
addMenu.add(studentAdd);
|
||||
addMenu.add(rentAdd);
|
||||
|
||||
// ”删除“菜单
|
||||
JMenu removeMenu = new JMenu("删除");
|
||||
JMenuItem bookRemove = new JMenuItem("删除图书信息");
|
||||
bookRemove.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Remover("books");
|
||||
}
|
||||
});
|
||||
JMenuItem studentRemove = new JMenuItem("删除学生信息");
|
||||
studentRemove.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Remover("students");
|
||||
}
|
||||
});
|
||||
JMenuItem rentRemove = new JMenuItem("删除借阅信息");
|
||||
rentRemove.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Remover("rents");
|
||||
}
|
||||
});
|
||||
removeMenu.add(bookRemove);
|
||||
removeMenu.add(studentRemove);
|
||||
removeMenu.add(rentRemove);
|
||||
|
||||
// ”关于“菜单
|
||||
JMenu aboutMenu = new JMenu("关于");
|
||||
JMenuItem about = new JMenuItem("关于软件");
|
||||
aboutDIalog = new aboutDIalog();
|
||||
about.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
aboutDIalog.setVisible(true);
|
||||
}
|
||||
});
|
||||
JMenuItem author = new JMenuItem("作者");
|
||||
authorDIalog = new AuthorDIalog();
|
||||
author.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
authorDIalog.setVisible(true);
|
||||
}
|
||||
});
|
||||
JMenuItem MITLicense = new JMenuItem("MIT许可证");
|
||||
MITLicense.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new MITDialog();
|
||||
}
|
||||
});
|
||||
JMenuItem thanksItem = new JMenuItem("鸣谢");
|
||||
thanksItem.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AcademyThanksDialog();
|
||||
}
|
||||
}
|
||||
);
|
||||
aboutMenu.add(about);
|
||||
aboutMenu.add(author);
|
||||
aboutMenu.add(MITLicense);
|
||||
aboutMenu.add(thanksItem);
|
||||
|
||||
//将菜单加入菜单栏
|
||||
add(fileMenu);
|
||||
add(searchMenu);
|
||||
add(addMenu);
|
||||
add(removeMenu);
|
||||
add(aboutMenu);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.AcademyThanksDialog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="OK"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="75e6c" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="bd601" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="新疆理工学院"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="51315" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="78840" class="javax.swing.JLabel" binding="imageLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class AcademyThanksDialog extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JLabel imageLabel;
|
||||
|
||||
public AcademyThanksDialog() {
|
||||
setTitle("鸣谢");
|
||||
setContentPane(contentPane);
|
||||
setModal(false);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
imageLabel.setIcon(new ImageIcon("src/com/msksbr/images/academy_logo.png"));
|
||||
pack();
|
||||
setResizable(false);
|
||||
setLocation();
|
||||
setAlwaysOnTop(true);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.Adder.BookAdder">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="添加"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="c66f9" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="a5571" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="eec5b" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<text value="书名:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="8fb87" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="bca8" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<text value="类别:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="f4a54" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="6fff7" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<text value="书号:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="5edf3" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4eb7a" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<text value="ISBN:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="6ff4f" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="7a6bb" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="7e1ba" class="javax.swing.JTextField" binding="textField1" default-binding="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="c22f4" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="dd3f3" class="javax.swing.JTextField" binding="textField2" default-binding="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="20b32" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4c60f" class="javax.swing.JTextField" binding="IDField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="db2b1" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="7e531" class="javax.swing.JTextField" binding="textField4" default-binding="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog.Adder;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
import com.msksbr.SQL.Connector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.print.Book;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class BookAdder extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JTextField textField1;
|
||||
private JTextField textField2;
|
||||
private JTextField IDField;
|
||||
private JTextField textField4;
|
||||
private Connector connector;
|
||||
private int bID;
|
||||
private String bName;
|
||||
private String bType;
|
||||
private String ISBN;
|
||||
private String sql;
|
||||
|
||||
public BookAdder() {
|
||||
|
||||
try {
|
||||
connector = new Connector();
|
||||
bID = getBookMaxID() + 1;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
|
||||
IDField.setText(String.valueOf(bID));
|
||||
IDField.setEditable(false);
|
||||
|
||||
setTitle("添加图书信息");
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
||||
setResizable(false);
|
||||
pack();
|
||||
setLocation();
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
bName = textField1.getText();
|
||||
bType = textField2.getText();
|
||||
ISBN = textField4.getText();
|
||||
sql = "INSERT INTO books (book_name,book_id,book_type,ISBN) VALUES ('" + bName + "'," + bID + ",'" + bType + "','" + ISBN + "');";
|
||||
commit2SQL();
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
|
||||
public int getBookMaxID() throws SQLException {
|
||||
ResultSet rs = connector.executeQuery("SELECT MAX(book_id) FROM books;");
|
||||
rs.next();
|
||||
return rs.getInt("MAX(book_id)");
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
private void commit2SQL() {
|
||||
try {
|
||||
connector.executeUpdate(sql);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.Adder.RentAdder">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="54" y="54" width="264" height="145"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="添加"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="e3beb" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9c1af" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="请输入书号:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c9df7" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="请输入学号:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="10667" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="60ed0" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5f80a" class="javax.swing.JTextField" binding="bIDField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="d1af9" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="26f68" class="javax.swing.JTextField" binding="sIDField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog.Adder;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
import com.msksbr.SQL.Connector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class RentAdder extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JTextField bIDField;
|
||||
private JTextField sIDField;
|
||||
private int bID;
|
||||
private int sID;
|
||||
private Connector bConnector;
|
||||
private Connector sConnector;
|
||||
private String bookSearchSQL;
|
||||
private String studentSearchSQL;
|
||||
private String updateSQL;
|
||||
private ResultSet bIDResult;
|
||||
private ResultSet sIDResult;
|
||||
|
||||
public RentAdder() {
|
||||
try {
|
||||
bConnector = new Connector();
|
||||
sConnector = new Connector();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
setTitle("添加借阅信息");
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
pack();
|
||||
setResizable(false);
|
||||
setLocation();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
try {
|
||||
this.bID = Integer.valueOf(bIDField.getText());
|
||||
this.sID = Integer.valueOf(sIDField.getText());
|
||||
searchSQLMaker();
|
||||
updateSQLMaker();
|
||||
bIDResult = bConnector.executeQuery(bookSearchSQL);
|
||||
sIDResult = sConnector.executeQuery(studentSearchSQL);
|
||||
if (!bIDResult.next()) {
|
||||
JOptionPane.showMessageDialog(this, "未找到该书信息", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
} else if (!sIDResult.next()) {
|
||||
JOptionPane.showMessageDialog(this, "未找到学生信息", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
if (bIDResult.getInt("borrowed_by") == 0) {
|
||||
bConnector.executeUpdate(updateSQL);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(this, "该书已借出", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
JOptionPane.showMessageDialog(this, "请输入一个整数", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
private void searchSQLMaker() {
|
||||
this.bookSearchSQL = "SELECT * FROM books WHERE book_id =" + this.bID + ";";
|
||||
this.studentSearchSQL = "SELECT * FROM students WHERE student_id =" + this.sID + ";";
|
||||
}
|
||||
|
||||
private void updateSQLMaker() {
|
||||
this.updateSQL = "UPDATE books SET borrowed_by = " + this.sID + " WHERE book_id =" + this.bID + ";";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.Adder.StudentAdder">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="添加"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="5c571" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="8e179" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<text value="姓名:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="19f7f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e5161" class="javax.swing.JTextField" binding="textField1" default-binding="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="4197b" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a91a6" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<text value="学号:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="6cf70" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="32fcc" class="javax.swing.JTextField" binding="IDField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="d8df3" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="adb15" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<text value="班级:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="cd800" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e20a7" class="javax.swing.JTextField" binding="textField3" default-binding="true">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="9af6b" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="bd9ba" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<text value="性别:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="d4804" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="8ce32" class="javax.swing.JRadioButton" binding="maleRadioButton">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="男"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="27c62" class="javax.swing.JRadioButton" binding="femaleRadioButton">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="女"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog.Adder;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
import com.msksbr.SQL.Connector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class StudentAdder extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JTextField textField1;
|
||||
private JTextField IDField;
|
||||
private JTextField textField3;
|
||||
private JRadioButton maleRadioButton;
|
||||
private JRadioButton femaleRadioButton;
|
||||
private Connector connector;
|
||||
private String sName;
|
||||
private int sID;
|
||||
private String sClass;
|
||||
private String sGender;
|
||||
private ButtonGroup genderGroup;
|
||||
private String sql;
|
||||
|
||||
public StudentAdder() {
|
||||
|
||||
try {
|
||||
connector = new Connector();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
genderGroup = new ButtonGroup();
|
||||
genderGroup.add(maleRadioButton);
|
||||
genderGroup.add(femaleRadioButton);
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
sID = getStudentMaxID() + 1;
|
||||
IDField.setText(String.valueOf(sID));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
IDField.setEditable(false);
|
||||
|
||||
setTitle("添加学生信息");
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
||||
setSize(new Dimension(260, 265));
|
||||
setResizable(false);
|
||||
pack();
|
||||
setLocation();
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
sName = textField1.getText();
|
||||
sClass = textField3.getText();
|
||||
sGender = maleRadioButton.isSelected() ? "男" : "女";
|
||||
sql = "INSERT INTO students (student_name,student_id,student_class,student_gender) VALUES ('" + sName + "'," + sID + ",'" + sClass + "','" + sGender + "');";
|
||||
commit2SQL();
|
||||
dispose();
|
||||
}
|
||||
|
||||
private void commit2SQL() {
|
||||
try {
|
||||
connector.executeUpdate(sql);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public int getStudentMaxID() throws SQLException {
|
||||
ResultSet rs = connector.executeQuery("SELECT MAX(student_id) FROM students;");
|
||||
rs.next();
|
||||
return rs.getInt("MAX(student_id)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.AuthorDIalog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="确认"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="fe414" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="56d70" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="1c1ff" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="14"/>
|
||||
<text value="https://gitee.com/msksbr"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="da859" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="1727d" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a162d" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="16" style="1"/>
|
||||
<text value="御坂昴"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e09f1" binding="iconPanel" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class AuthorDIalog extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JPanel iconPanel;
|
||||
|
||||
public AuthorDIalog() {
|
||||
setContentPane(contentPane);
|
||||
setModal(false);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
setVisible(false);
|
||||
JLabel authorLabel = new JLabel();
|
||||
authorLabel.setIcon(new ImageIcon("src/com/msksbr/images/AuthorProfile.jpg"));
|
||||
iconPanel.add(authorLabel);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setTitle("作者");
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
setResizable(false);
|
||||
setAlwaysOnTop(true);
|
||||
pack();
|
||||
setLocation();
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.MITDialog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="366"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="e3588" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a6e23" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="本项目已在gitee.com开源"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="94766" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="确认"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="f0964" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="802af" class="javax.swing.JTextPane" binding="MITPane">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class MITDialog extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JTextPane MITPane;
|
||||
|
||||
public MITDialog() {
|
||||
setTitle("开源信息");
|
||||
MITPane.setEditable(false);
|
||||
MITPane.setText("MIT License\n" +
|
||||
"\n" +
|
||||
"Copyright (c) 2024 御坂昴\n" +
|
||||
"\n" +
|
||||
"Permission is hereby granted, free of charge, to any person obtaining a copy\n" +
|
||||
"of this software and associated documentation files (the \"Software\"), to deal\n" +
|
||||
"in the Software without restriction, including without limitation the rights\n" +
|
||||
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n" +
|
||||
"copies of the Software, and to permit persons to whom the Software is\n" +
|
||||
"furnished to do so, subject to the following conditions:\n" +
|
||||
"\n" +
|
||||
"The above copyright notice and this permission notice shall be included in all\n" +
|
||||
"copies or substantial portions of the Software.\n" +
|
||||
"\n" +
|
||||
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" +
|
||||
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" +
|
||||
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" +
|
||||
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" +
|
||||
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" +
|
||||
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n" +
|
||||
"SOFTWARE.\n");
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
setModal(false);
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
|
||||
pack();
|
||||
setResizable(false);
|
||||
setLocation();
|
||||
setAlwaysOnTop(true);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.Remover">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="删除"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="1b7c" class="javax.swing.JLabel" binding="idLable">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="8147a" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="19c5" class="javax.swing.JTextField" binding="idField">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<columns value="15"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
import com.msksbr.SQL.Connector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Remover extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JLabel idLable;
|
||||
private JTextField idField;
|
||||
private String table;
|
||||
private String Searchsql;
|
||||
private String searchSQL;
|
||||
private String deleteSQL;
|
||||
private String searchErrMsg;
|
||||
private int id;
|
||||
private Connector searchConnector;
|
||||
private Connector deleteConnector;
|
||||
|
||||
public Remover(String table) {
|
||||
try {
|
||||
searchConnector = new Connector();
|
||||
deleteConnector = new Connector();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
this.table = table;
|
||||
if (table.equals("books")) {
|
||||
setTitle("删除图书信息");
|
||||
idLable.setText("请输入书号:");
|
||||
searchErrMsg = "未找到该图书信息";
|
||||
} else if (table.equals("students")) {
|
||||
setTitle("删除学生信息");
|
||||
idLable.setText("请输入学号:");
|
||||
searchErrMsg = "未找到该学生信息";
|
||||
} else if (table.equals("rents")) {
|
||||
setTitle("删除借阅信息");
|
||||
idLable.setText("请输入书号:");
|
||||
searchErrMsg = "未找到该借阅信息";
|
||||
}
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
pack();
|
||||
setResizable(false);
|
||||
setLocation();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
try {
|
||||
this.id = Integer.valueOf(idField.getText());
|
||||
searchSQLMaker();
|
||||
deleteSQLMaker();
|
||||
ResultSet rs = searchConnector.executeQuery(searchSQL);
|
||||
if (rs.next()) {
|
||||
deleteConnector.executeUpdate(deleteSQL);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(this, searchErrMsg, "错误", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
JOptionPane.showMessageDialog(this, "请输入一个整数", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
|
||||
private void searchSQLMaker() {
|
||||
if (table.equals("books")) {
|
||||
searchSQL = "select * from " + table + " where book_id=" + id + ";";
|
||||
} else if (table.equals("students")) {
|
||||
searchSQL = "select * from " + table + " where student_id=" + id + ";";
|
||||
} else if (table.equals("rents")) {
|
||||
searchSQL = "select * from " + table + " where book_id=" + id + ";";
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteSQLMaker() {
|
||||
if (table.equals("books")) {
|
||||
deleteSQL = "delete from " + table + " where book_id=" + id + ";";
|
||||
} else if (table.equals("students")) {
|
||||
deleteSQL = "delete from " + table + " where student_id=" + id + ";";
|
||||
} else if (table.equals("rents")) {
|
||||
deleteSQL = "UPDATE books SET borrowed_by = null WHERE book_id=" + id + ";";
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.SearchDIalog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="查询"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="8f9fb" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a8662" class="javax.swing.JLabel" binding="messageLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="请输入学号:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="c8446">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="36605">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="87c34" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="90640" class="javax.swing.JTextField" binding="idFIeld">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<columns value="10"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="a6bdf">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="ceec6">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
import com.msksbr.SQL.Connector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SearchDIalog extends JDialog {
|
||||
public JLabel messageLabel;
|
||||
protected int idInt;
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JTextField idFIeld;
|
||||
private String table;
|
||||
|
||||
public SearchDIalog(String table) {
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
if (table.equals("books")) {
|
||||
this.table = "books";
|
||||
this.setTitle("查询图书信息");
|
||||
messageLabel.setText("请输入书号:");
|
||||
} else if (table.equals("students")) {
|
||||
this.table = "students";
|
||||
this.setTitle("查询学生信息");
|
||||
messageLabel.setText("请输入学号:");
|
||||
} else if (table.equals("rents")) {
|
||||
this.table = "rents";
|
||||
this.setTitle("查询借阅信息");
|
||||
messageLabel.setText("请输入书号:");
|
||||
}
|
||||
setListener();
|
||||
pack();
|
||||
setLocation();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void setListener() {
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
idFIeld.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
onOK();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
ResultSet rs = SQLExe();
|
||||
String message = "";
|
||||
try {
|
||||
if (rs != null && rs.next()) {
|
||||
String title = "";
|
||||
if (table.equals("books")) {
|
||||
message = "书名:\t" + rs.getString("book_name") + "\n类别:\t" + rs.getString("book_type") + "\n书号:\t" + rs.getInt("book_id") + "\nISBN:\t" + rs.getString("ISBN");
|
||||
title = "图书信息";
|
||||
} else if (table.equals("students")) {
|
||||
message = "学生姓名:\t" + rs.getString("student_name") + "\n学号:\t" + rs.getInt("student_id") + "\n班级:\t" + rs.getString("student_class") + "\n性别:\t" + rs.getString("student_gender");
|
||||
title = "学生信息";
|
||||
} else if (table.equals("rents")) {
|
||||
message = "学生姓名:\t" + rs.getString("student_name") + "\n学号:\t" + rs.getInt("student_id") + "\n班级:\t" + rs.getString("student_class") + "\n性别:\t" + rs.getString("student_gender") + "\n书名:\t" + rs.getString("book_name") + "\n书号:\t" + rs.getInt("book_id") + "\n类别:\t" + rs.getString("book_type") + "\nISBN:\t" + rs.getString("ISBN");
|
||||
title = "借阅信息";
|
||||
}
|
||||
new showMessae(message, title);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(this, "未找到", "未找到", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ResultSet SQLExe() {
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
idInt = Integer.valueOf(idFIeld.getText());
|
||||
Connector connector = new Connector();
|
||||
rs = connector.executeQuery(SQLExeMaker(table));
|
||||
} catch (NumberFormatException e) {
|
||||
JOptionPane.showMessageDialog(this, "请输入一个整数", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
private String SQLExeMaker(String table) {
|
||||
if (table.equals("books")) {
|
||||
return "SELECT * FROM `books` WHERE `book_id` = " + idInt + ";";
|
||||
} else if (table.equals("students")) {
|
||||
return "SELECT * FROM `students` WHERE `student_id` = " + idInt + ";";
|
||||
} else if (table.equals("rents")) {
|
||||
return "SELECT * FROM `rents` WHERE `book_id` = " + idInt + ";";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.aboutDIalog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="确认"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="f8413" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="48047" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="14"/>
|
||||
<text value="https://gitee.com/msksbr/system-homework-in-the-library"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="bae5e" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b98e5" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="58e29" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font name="PingFang SC" size="16" style="1"/>
|
||||
<text value="图书管理系统 Demo"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="d8804" binding="iconPanel" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class aboutDIalog extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JPanel iconPanel;
|
||||
|
||||
public aboutDIalog() {
|
||||
setTitle("关于图书管理系统");
|
||||
setVisible(false);
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
setResizable(false);
|
||||
JLabel iconLabel = new JLabel();
|
||||
iconLabel.setIcon(new ImageIcon("src/com/msksbr/images/logo_128.png"));
|
||||
iconPanel.add(iconLabel);
|
||||
setModal(false);
|
||||
setAlwaysOnTop(true);
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
pack();
|
||||
setLocation();
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.MainFrm.MenuItemDiaog.showMessae">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="OK"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="165c3" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="b32d2" class="javax.swing.JTextPane" binding="textPane1" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="text"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.msksbr.MainFrm.MenuItemDiaog;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class showMessae extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JTextPane textPane1;
|
||||
|
||||
public showMessae(String message, String title) {
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
this.textPane1.setText(message);
|
||||
this.setTitle(title);
|
||||
textPane1.setEditable(false);
|
||||
pack();
|
||||
setResizable(false);
|
||||
setCenterLocation();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void setCenterLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.msksbr.SQL;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class Connector {
|
||||
private Connection conn;
|
||||
private Statement stmt;
|
||||
private String url="sqlmsksbr.com";
|
||||
private Integer port=1433;
|
||||
private String username="sa";
|
||||
private String password="nothx";
|
||||
private String database="book";
|
||||
private Boolean encrypted=false;
|
||||
|
||||
private String loginURL=new UserInfo(url,port,database,username,password,encrypted).GetUserInfo();
|
||||
|
||||
public Connector() throws ClassNotFoundException, SQLException {
|
||||
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||
conn = DriverManager.getConnection(loginURL);
|
||||
stmt = conn.createStatement();
|
||||
}
|
||||
|
||||
public ResultSet executeQuery(String query) throws SQLException {
|
||||
return stmt.executeQuery(query);
|
||||
}
|
||||
|
||||
public int executeUpdate(String query) throws SQLException {
|
||||
return stmt.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.msksbr.SQL;
|
||||
|
||||
public class UserInfo {
|
||||
private String url;
|
||||
private Integer port;
|
||||
private String database;
|
||||
private String username;
|
||||
private String password;
|
||||
private Boolean encrypted;
|
||||
|
||||
public UserInfo(String url, Integer port, String database, String username, String password,boolean encrypted) {
|
||||
this.url = url;
|
||||
this.port = port;
|
||||
this.database = database;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
|
||||
public String GetUserInfo(){
|
||||
String LoginURL;
|
||||
LoginURL = "jdbc:sqlserver://";
|
||||
LoginURL=LoginURL+url;
|
||||
LoginURL=LoginURL+":"+port.toString();
|
||||
LoginURL=LoginURL+";databaseName="+database;
|
||||
LoginURL=LoginURL+";user="+username;
|
||||
LoginURL=LoginURL+";password="+password;
|
||||
LoginURL=LoginURL+";encrypt="+encrypted.toString().toLowerCase();
|
||||
return LoginURL;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 75 KiB |
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.msksbr.images.EasterEgg">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="94766" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Coding!"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="3b48b" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="76717" class="javax.swing.JLabel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<font size="14" style="1"/>
|
||||
<text value="Coding with JavaBeans!"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="283b1" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9b6a4" class="javax.swing.JLabel" binding="imageLable">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="29912">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="5cc54">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.msksbr.images;
|
||||
|
||||
import com.msksbr.LoginFrm.ScreenSize;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class EasterEgg extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JLabel imageLable;
|
||||
|
||||
public EasterEgg() {
|
||||
setTitle("Easter Egg!");
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
imageLable.setIcon(new ImageIcon("src/com/msksbr/images/BuzzBeans.png"));
|
||||
|
||||
buttonOK.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onOK();
|
||||
}
|
||||
});
|
||||
|
||||
pack();
|
||||
setResizable(false);
|
||||
setLocation();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
// 在此处添加您的代码
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void setLocation() {
|
||||
setLocation(new ScreenSize().width / 2 - getWidth() / 2, new ScreenSize().height / 2 - getHeight() / 2);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 111 KiB |