?? deletelibr.java
字號:
package client;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import com.swtdesigner.SwingResourceManager;
import sever.business.iface.ILibrarianInfoIface;
import sever.business.impl.IlibrarianInfoImpl;
import sever.dao.LibrarianInfoDAO;
import sever.db.ConnectionDB;
import sever.entity.BookInfo;
import sever.entity.LibrarianInfo;
public class DeleteLibr extends JFrame {
/**
* Launch the application
* @param args
*/
ImageIcon image=new ImageIcon("E:\\image\\1.JPG");
ImageIcon image2=new ImageIcon("E:\\image\\3.JPG");
//ImageIcon image3=new ImageIcon("E:\\image\\2.JPG");
// public static void main(String args[]) {
// try {
// DeleteLibr frame = new DeleteLibr();
// frame.setVisible(true);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* Create the frame
*/
public DeleteLibr() {
super();
setIconImage(SwingResourceManager.getImage(DeleteLibr.class, "/LOGO.jpg"));
getContentPane().setBackground(new Color(224, 235, 237));
getContentPane().setLayout(null);
setBounds(100, 100,365, 208);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("刪除管理員");
final JLabel label = new JLabel();
label.setFont(new Font("@黑體", Font.PLAIN, 14));
label.setText("按編號:");
label.setBounds(21, 42, 60, 15);
getContentPane().add(label);
final JTextField textField = new JTextField();
textField.setBounds(87, 37, 99, 25);
getContentPane().add(textField);
final JLabel label_1 = new JLabel();
label_1.setFont(new Font("@黑體", Font.PLAIN, 14));
label_1.setText("按姓名:");
label_1.setBounds(21, 90, 60, 15);
getContentPane().add(label_1);
final JTextField textField_1 = new JTextField();
textField_1.setBounds(87, 85, 99, 25);
getContentPane().add(textField_1);
final JButton button = new JButton();
button.setText("確認");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(textField.getText().length()==0){
JOptionPane.showMessageDialog(null,"請輸入編號");
}
else{
int i=JOptionPane.showOptionDialog(null, "是否刪除", "警告", JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION, null, null, null);
if(i==0){
LibrarianInfo book=new LibrarianInfo();
book.setLibrarianId(Integer.parseInt(textField.getText().trim()));
ILibrarianInfoIface face=new IlibrarianInfoImpl();
boolean bl=face.delectpel(book);
}else{
dispose();
}
}
//按編號刪除管理人員
}
});
button.setFont(new Font("@黑體", Font.PLAIN, 14));
button.setBounds(194, 37, 70, 25);
getContentPane().add(button);
final JButton button_1 = new JButton();
button_1.setText("確認");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(textField_1.getText().length()==0){
JOptionPane.showMessageDialog(null,"請輸入用戶名");
}
else{
int i=JOptionPane.showOptionDialog(null, "是否刪除", "警告", JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION, null, null, null);
if(i==0){
LibrarianInfo book=new LibrarianInfo();
book.setLibrarianName(textField_1.getText().trim());
ILibrarianInfoIface face=new IlibrarianInfoImpl();
boolean bl=face.deletepele(book);
}else{
dispose();
}
}
}
});
button_1.setFont(new Font("@黑體", Font.PLAIN, 14));
button_1.setBounds(194, 85, 70, 25);
getContentPane().add(button_1);
final JLabel label_2 = new JLabel();
label_2.setBorder(new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
label_2.setBounds(80, 127, 211, 25);
getContentPane().add(label_2);
final JButton button_2 = new JButton();
button_2.setFont(new Font("@黑體", Font.PLAIN, 14));
button_2.setText("驗證");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LibrarianInfo lir=new LibrarianInfo();
lir.setLibrarianId(Integer.parseInt(textField.getText().trim()));
ILibrarianInfoIface lirbr=new IlibrarianInfoImpl();
boolean boo=lirbr.checkNumber(lir);
if(boo==true){
label_2.setText("該管理員存在");
}else{
label_2.setText("該管理員不存在");
}
}
});
button_2.setBounds(270, 37, 70, 25);
getContentPane().add(button_2);
final JButton button_3 = new JButton();
button_3.setFont(new Font("@黑體", Font.PLAIN, 14));
button_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LibrarianInfo libr=new LibrarianInfo();
libr.setLibrarianName(textField_1.getText().trim());
ILibrarianInfoIface lir=new IlibrarianInfoImpl();
boolean bool=lir.checkName(libr);
if(bool==true){
label_2.setText("該管理員存在");
}else{
label_2.setText("該管理員不存在");
}
}
});
button_3.setText("驗證");
button_3.setBounds(270, 86, 70, 25);
getContentPane().add(button_3);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -