Chức năng quản lý nhân viên
Một số hàm cơ bản của chức năng
a Hàm lấy dữ liệu bảng nhân viên từ SQL public void nhapdulieusql()
String sql="select * from nhanvien";
PreparedStatement cmd= ketnoi.cn.prepareStatement(sql); ResultSet rs= cmd.executeQuery(); while(rs.next()) {
String s=rs.getString(1)+";"+rs.getString(2)+";"+rs.getString(3)+";"+rs.getString(4)+";"+r s.getString(5); a.add(s);
} rs.close(); ketnoi.cn.close();
} b Hàm in dữ liệu bảng nhân viên ra màn hình public void hienthi()
DefaultTableModel mh=new DefaultTableModel(); mh.addColumn("Mã nhân viên"); mh.addColumn("Tên nhân viên"); mh.addColumn("Chứng minh thư"); mh.addColumn("Địa chỉ"); mh.addColumn("Số điện thoại");
Object[] t=new Object[5]; t=s; mh.addRow(t);
} c Hàm lưu thông tin một nhân viên mới vào dữ liệu SQL public void luu(String st)
String sql="insert into nhanvien values(?,?,?,?,?)";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql);
String[] s=st.split("[;]"); cmp.setString(1, s[0]); cmp.setString(2, s[1]); cmp.setString(3, s[2]); cmp.setString(4, s[3]); cmp.setString(5, s[4]); cmp.executeUpdate(); cmp.close();
} catch (Exception ex) { ex.getStackTrace();
6 d Hàm xóa thông tin một nhân viên trong dữ liệu SQL public void xoa(String st)
String sql="Delete From nhanvien Where manv=?";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql); cmp.setString(1, st); cmp.executeUpdate();
} catch (Exception ex) { ex.getStackTrace();
} } e Hàm sửa thông tin một nhân viên trong dữ liệu SQL
Public void capnhat(String st)
String sql=”Update nhanvien set tennv=?, CMND=?, diachi=?, SDT=? Where manv=?”;
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql); String[] s=st.split(“[;]”); cmp.setString(1,s[1]); cmp.setString(2,s[2]); cmp.setString(3,s[3]); cmp.setString(4,s[4]); cmp.setString(5,s[0]);
} catch (Exception ex) { ex.getStackTrace();
} } f Hàm kiểm tra mã nhân viên mỗi khi thêm một nhân viên
Public int ktmanv(String stt)
String[] st1=a.get(i).split(“[;]”); if ( stt.equalsIgnoreCase(st1[0])==true) return 0;
Toàn bộ code chức năng quản lý nhân viên
This Java code snippet demonstrates the creation of a graphical user interface (GUI) using the Swing framework It imports essential classes such as JFrame for the main window, JLabel for text display, JPanel for organizing components, and JScrollPane for adding scrollable views The code also includes DefaultTableModel for managing table data, JTabbedPane for tabbed interfaces, JTextField for user input, and JMenuBar along with JMenu for menu options This setup is crucial for developing interactive Java applications with a structured layout and user-friendly navigation.
This Java code snippet defines a class named `nhanvien`, which extends `JFrame` to create a graphical user interface (GUI) for managing employee data It imports various AWT and Swing components, including `Color`, `TextField`, `JMenuItem`, and `JTable`, to facilitate user interaction The class contains multiple text fields for input and a table for displaying data Additionally, it includes event listeners for mouse and action events, enabling dynamic user interactions The code also sets up file handling capabilities for reading from and writing to files, as well as database operations using `PreparedStatement` and `ResultSet`.
*/ public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() { public void run() { try { nhanvien frame = new nhanvien(); frame.setVisible(true);
*/ public ArrayList a=new ArrayList(); public ArrayList b=new ArrayList(); public int d=-1; public void nhapdulieusql()
String sql="select * from nhanvien";
PreparedStatement cmd= ketnoi.cn.prepareStatement(sql);
ResultSet rs= cmd.executeQuery(); while(rs.next())
String s=rs.getString(1)+";"+rs.getString(2)+";"+rs.getString(3)+";"+rs.getString(4)+";"+rs.getSt ring(5); a.add(s);
} rs.close(); ketnoi.cn.close();
Đoạn mã dưới đây khởi tạo một đối tượng DefaultTableModel mới và thêm các cột "Mã nhân viên", "Tên nhân viên", "Chứng minh thư", "Địa chỉ" và "Số điện thoại" vào mô hình bảng Sau đó, một vòng lặp for được sử dụng để lặp qua danh sách a.
Object[] t=new Object[5]; t=s; mh.addRow(t);
} public void luu(String st)
String sql="insert into nhanvien values(?,?,?,?,?)";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql); String[] s=st.split("[;]"); cmp.setString(1, s[0]); cmp.setString(2, s[1]); cmp.setString(3, s[2]); cmp.setString(4, s[3]); cmp.setString(5, s[4]); cmp.executeUpdate(); cmp.close();
} public void xoa(String st)
String sql="Delete From nhanvien Where manv=?";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql); cmp.setString(1, st); cmp.executeUpdate();
} public void capnhat(String st)
String sql="Update nhanvien set tennv=?, CMND=?, diachi=?, SDT=? Where manv=?";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql);
String[] s=st.split("[;]"); cmp.setString(1,s[1]); cmp.setString(2,s[2]); cmp.setString(3,s[3]); cmp.setString(4,s[4]); cmp.setString(5,s[0]); cmp.executeUpdate();
} public int ktmanv(String stt)
String[] st1=a.get(i).split("[;]"); if ( stt.equalsIgnoreCase(st1[0])==true) return 0;
The code snippet demonstrates how to split a string from an array at a specified delimiter and populate multiple text fields with the resulting values It uses the `split` method to divide the string at semicolons and assigns the first value to `textField_2` Subsequent values are checked for null before being assigned to `textField_3`, `textField_4`, `textField_5`, and `textField_6`, ensuring that only non-null values are displayed.
The "Pet Management Software" application is designed with a user-friendly interface, featuring a red foreground and a light highlight background It operates within a defined window size of 801 by 687 pixels and ensures a smooth user experience by setting the default close operation to exit The content pane is organized without layout constraints, allowing for flexible component placement.
JMenuBar menuBar = new JMenuBar(); menuBar.setBackground(Color.WHITE); menuBar.setBounds(0, 0, 542, 25); contentPane.add(menuBar);
The code snippet creates a new menu titled "Hệ thống" with a font style of "Segoe UI" at a size of 15 This menu is set to be disabled, ensuring that it cannot be interacted with The text color is defined as black, while the background color is set to white, providing a clear contrast Finally, this menu is added to the menu bar for display.
JMenu mnNewMenu_1 = new JMenu("Ch\u1EE9c n\u0103ng"); mnNewMenu_1.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { kygui hd=new kygui(); hd.setVisible(true);
13 mnNewMenu_1.setEnabled(false); mnNewMenu_1.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_1.setBackground(Color.WHITE); mnNewMenu_1.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_1);
JMenu mnNewMenu_3 = new JMenu("H\u00E0ng h\u00F3a"); mnNewMenu_3.setEnabled(false); mnNewMenu_3.addMouseListener(new MouseAdapter() {
@Override public void mouseClicked(MouseEvent e) { xemkho xk= new xemkho(); xk.setVisible(true);
The menu bar features a new menu titled "Nhân sự," designed with a bold Segoe UI font at size 15, complemented by a white background and black text Additionally, another menu is included with a plain Segoe UI font at size 15, maintaining the same black text color.
JMenu mnNewMenu_4 = new JMenu("Kh\u00E1ch h\u00E0ng"); mnNewMenu_4.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_4.setEnabled(false); mnNewMenu_4.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_4);
JMenu mnNewMenu_5 = new JMenu("B\u00E1o c\u00E1o"); mnNewMenu_5.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_5.setEnabled(false); mnNewMenu_5.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_5);
JMenu mnNewMenu_6 = new JMenu("Gi\u00FAp \u0111\u1EE1"); mnNewMenu_6.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_6.setEnabled(false); mnNewMenu_6.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_6);
JLabel lblNewLabel = new JLabel("Mã nhân viên"); lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblNewLabel.setBounds(29, 158, 87, 16);
In the Java Swing application, a JLabel is created with the text "Họ tên," styled with a Tahoma font at a size of 14 This label is positioned within the content pane at coordinates (33, 202) Additionally, two JTextFields are added to the interface; the first JTextField is set at (126, 152) and the second at (126, 202), both with a width of 104 and a height of 22 Each JTextField is configured to accommodate up to 10 columns of text.
JLabel lblNewLabel_2 = new JLabel("Địa chỉ"); lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_2.setBounds(261, 158, 68, 16); contentPane.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("Chứng minh"); lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_3.setBounds(254, 202, 87, 16); contentPane.add(lblNewLabel_3);
In the user interface, a JLabel labeled "SĐT" is created with a Tahoma font at a size of 15, positioned at coordinates (494, 202) Additionally, three JTextFields are implemented: the first JTextField is set at (351, 152) with a width of 104 and a height of 22, the second at (351, 202) with the same dimensions, and the third at (574, 202) also measuring 104 in width and 22 in height Each JTextField is configured to accept up to 10 columns of input.
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(54, 308, 554, 249); contentPane.add(tabbedPane);
JScrollPane scrollPane = new JScrollPane(); tabbedPane.addTab("", null, scrollPane, null); table = new JTable(); table.setBackground(Color.CYAN); scrollPane.setViewportView(table); nhapdulieusql(); hienthi();
JButton btnNewButton_4 = new JButton("Lưu"); btnNewButton_4.setBackground(Color.WHITE); btnNewButton_4.setFont(new Font("Tahoma", Font.BOLD, 15)); btnNewButton_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(btnNewButton_4, "Nhập mã nhân viên"); else if ((ktmanv(s1)==0))
JOptionPane.showMessageDialog(btnNewButton_4, "Mã nhân viên đã tồn tại Yêu cầu nhập lại"); else { luu(st); a.add(st); hienthi();}
String[] s=a.get(d).split("[;]"); capnhat(st);
{ if (j==d) b.add(st); else b.add(a.get(j)); a.remove(j);
} textField_2.setText(""); textField_3.setText(""); textField_4.setText(""); textField_5.setText(""); textField_6.setText("");
}); btnNewButton_4.setBounds(126, 273, 68, 25); contentPane.add(btnNewButton_4);
JButton btnNewButton_5 = new JButton("Sửa"); btnNewButton_5.setBackground(Color.WHITE); btnNewButton_5.setFont(new Font("Tahoma", Font.BOLD, 15)); btnNewButton_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int n=table.getSelectedRow(); setdata(n); d=n;
}); btnNewButton_5.setBounds(447, 273, 68, 25); contentPane.add(btnNewButton_5);
JButton btnNewButton_6 = new JButton("Xóa"); btnNewButton_6.setBackground(Color.WHITE); btnNewButton_6.setFont(new Font("Tahoma", Font.BOLD, 15)); btnNewButton_6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int n=table.getSelectedRow();
String[] ss=a.get(n).split("[;]"); a.remove(n);
}); btnNewButton_6.setBounds(280, 273, 68, 25); contentPane.add(btnNewButton_6);
JButton btnNewButton_7 = new JButton("Đăng xuất"); btnNewButton_7.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { dangnhap dn= new dangnhap(); dn.setVisible(true);
}); btnNewButton_7.setFont(new Font("Tahoma", Font.BOLD, 15)); btnNewButton_7.setBounds(248, 580, 119, 23); contentPane.add(btnNewButton_7);
JLabel anh1 = new JLabel(""); anh1.setBounds(21, 30, 52, 40); contentPane.add(anh1);
ImageIcon icon= new ImageIcon("d:/java/1.png"); anh1.setIcon(icon);
JLabel anh2 = new JLabel(""); anh2.setBounds(157, 26, 54, 40); contentPane.add(anh2);
ImageIcon icon1= new ImageIcon("d:/java/2.png"); anh2.setIcon(icon1);
JLabel anh3 = new JLabel(""); anh3.setBounds(303, 30, 45, 40); contentPane.add(anh3);
ImageIcon icon2= new ImageIcon("d:/java/3.png"); anh3.setIcon(icon2);
JLabel anh4 = new JLabel(""); anh4.setBounds(430, 30, 52, 40); contentPane.add(anh4);
ImageIcon icon3= new ImageIcon("d:/java/4.png"); anh4.setIcon(icon3);
JLabel lblNewLabel_5 = new JLabel("Nhân Viên"); lblNewLabel_5.setForeground(Color.CYAN);
18 lblNewLabel_5.setFont(new Font("Tahoma", Font.BOLD, 15)); lblNewLabel_5.setBounds(10, 80, 87, 19); contentPane.add(lblNewLabel_5);
JLabel lblNewLabel_5_1 = new JLabel("Chấm công"); lblNewLabel_5_1.setFont(new Font("Tahoma", Font.BOLD, 15)); lblNewLabel_5_1.setBounds(134, 83, 96, 19); contentPane.add(lblNewLabel_5_1);
JLabel lblNewLabel_5_1_1 = new JLabel("Quy định"); lblNewLabel_5_1_1.setFont(new Font("Tahoma", Font.BOLD, 15)); lblNewLabel_5_1_1.setBounds(290, 83, 77, 19); contentPane.add(lblNewLabel_5_1_1);
JLabel lblNewLabel_5_1_2 = new JLabel("Chính sách"); lblNewLabel_5_1_2.setFont(new Font("Tahoma", Font.BOLD, 15)); lblNewLabel_5_1_2.setBounds(414, 80, 87, 19); contentPane.add(lblNewLabel_5_1_2);
JButton btnNewButton = new JButton(""); btnNewButton.setBackground(Color.BLACK); btnNewButton.setBounds(29, 144, 423, 4); contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("New button"); btnNewButton_1.setBackground(Color.BLACK); btnNewButton_1.setBounds(16, 158, 3, 99); contentPane.add(btnNewButton_1);
} private static void addPopup(Component component, final JPopupMenu popup) { component.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e);
} public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e);
} private void showMenu(MouseEvent e) { popup.show(e.getComponent(), e.getX(), e.getY());
Chức năng quản lý chuồng và thông tin ký gửi
Giao diện màn hình chức năng quản lý chuồng và thông tin ký gửi
2 Một số hàm cơ bản của chức năng a Hàm nhập dữ liệu thông tin ký gửi từ SQL
String sql=”select * from thongtinkygui”;
PreparedStatement cmd= ketnoi.cn.prepareStatement(sql);
ResultSet rs= cmd.executeQuery(); while(rs.next()) {
String s=rs.getString(1)+”;”+rs.getString(2)+”;”+rs.getString(3)+”;”+rs.getString(4)+”;”+r s.getString(5)+”;”+rs.getString(6)+”;”+rs.getString(7)+”;”+rs.getString(8)+”;”+rs.g etString(9)+”;”+rs.getString(10)+”;”+rs.getString(11)+”;”+rs.getString(12); a.add(s);
} rs.close(); ketnoi.cn.close();
} } b Hàm lưu thông tin ký gửi khi đăng ký ký gửi pes mới trong dữ liệu SQL public void luu(String st)
String sql="insert into thongtinkygui values(?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql);
String[] s=st.split("[;]"); cmp.setString(1, s[0]); cmp.setString(2, s[1]); cmp.setString(3, s[2]); cmp.setString(4, s[3]);
21 cmp.setString(5, s[4]); cmp.setString(6, s[5]); cmp.setString(7, s[6]); cmp.setString(8, s[7]); cmp.setString(9, s[8]); cmp.setString(10, s[9]); cmp.setString(11, s[10]); cmp.setString(12, s[11]); cmp.executeUpdate(); cmp.close();
} catch (Exception ex) { ex.getStackTrace();
} } c Hàm xóa thông tin ký gửi của một chuồng trong dữ liệu SQL public void xoa(String st)
PreparedStatement cmp=ketnoi.cn.prepareStatement("Delete From thongtinkygui Where makygui=?"); cmp.setString(1, st); cmp.executeUpdate();
} } d Hàm cập nhật lại thông tin của một chuồng trong dữ liệu SQL public void capnhat(String st,String t)
String sql="Update thongtinkygui set tenchu=?,lienhe=?,cmnd=?,tenpes=?,soluong=?,ngaygui=?,ngaytra=?,giacombo=?, manhanvien=?,tenchuong=?,giayto=? Where makygui=?";
To execute a SQL statement using PreparedStatement, first, establish a connection with `ketnoi.cn.prepareStatement(sql)` Next, split the input string `st` using a semicolon as the delimiter and store the results in an array `s` Set the parameters for the PreparedStatement by assigning values from the array `s` to the appropriate placeholders, from index 1 to 11, and a variable `t` for the twelfth parameter Finally, execute the update with `cmp.executeUpdate()` and close the PreparedStatement with `cmp.close()`.
} } e Hàm kiểm tra ngày trả pes với thời gian hiện tại có hợp lý hay không public int kiemtrangay(String st)
SimpleDateFormat sim=new SimpleDateFormat("dd/MM/yyyy"); long t = date.getTime(); dte=sim.format(date.getTime());
Date t1= sim.parse(st); long t2=t1.getTime(); if (t>t2) return 0; else return 1;
// TODO Auto-generated catch block e.printStackTrace();
Toàn bộ code chức năng quản lý chuồng và thông tin ký gửi
This Java code snippet utilizes the AWT (Abstract Window Toolkit) library to create a graphical user interface (GUI) with a BorderLayout It imports essential classes for handling colors, fonts, components, and mouse events The code sets the stage for developing interactive applications by leveraging event handling through MouseAdapter to respond to user interactions.
The Java program defines a class named `kygui` that extends `JFrame`, creating a graphical user interface (GUI) for an application It imports essential libraries for SQL operations, date formatting, and various Swing components, including panels, buttons, and menus The class initializes a content pane and text fields for user input, enabling interaction within the GUI This setup is crucial for developing a functional and user-friendly interface in Java applications.
*/ public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() { public void run() { try { kygui frame = new kygui(); frame.setVisible(true);
The code initializes an ArrayList of strings and two integer arrays, each with a size of 16 It also declares two integer variables, p and pp, along with a string variable dte Multiple JTextField objects are instantiated for user input, including textField, textField_1, textField_2, textField_3, textField_4, textField_6, textField_7, textField_8, textField_9, and textField_11 The method nhapdulieusql() is defined to handle SQL data input.
String sql="select * from thongtinkygui";
PreparedStatement cmd= ketnoi.cn.prepareStatement(sql);
ResultSet rs= cmd.executeQuery(); while(rs.next())
String s=rs.getString(1)+";"+rs.getString(2)+";"+rs.getString(3)+";"+rs.getString(4)+";"+rs.getSt
26 ring(5)+";"+rs.getString(6)+";"+rs.getString(7)+";"+rs.getString(8)+";"+rs.getString(9)+";
"+rs.getString(10)+";"+rs.getString(11)+";"+rs.getString(12); a.add(s);
} rs.close(); ketnoi.cn.close();
} public void luu(String st)
String sql="insert into thongtinkygui values(?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql);
The code snippet begins by splitting a string `st` into an array `s` using a semicolon as the delimiter It then sets multiple string parameters in a prepared statement `cmp` with the values from the array, ranging from the first to the twelfth element After populating the parameters, it executes the update and subsequently closes the prepared statement.
} public void xoa(String st)
PreparedStatement cmp=ketnoi.cn.prepareStatement("Delete From thongtinkygui Where makygui=?"); cmp.setString(1, st); cmp.executeUpdate();
} public void capnhat(String st,String t)
String sql="Update thongtinkygui set tenchu=?,lienhe=?,cmnd=?,tenpes=?,soluong=?,ngaygui=?,ngaytra=?,giacombo=?,manha nvien=?,tenchuong=?,giayto=? Where makygui=?";
PreparedStatement cmp=ketnoi.cn.prepareStatement(sql);
The code snippet demonstrates how to split a string `st` into an array `s` using a semicolon as the delimiter It then sets multiple parameters in a prepared statement `cmp` using the values from the array, specifically from index 1 to index 11, and also sets an additional parameter with the variable `t` Finally, the prepared statement is executed and closed, ensuring efficient database interaction.
} public int kiemtrangay(String st)
SimpleDateFormat sim=new SimpleDateFormat("dd/MM/yyyy"); long t = date.getTime(); dte=sim.format(date.getTime());
Date t1= sim.parse(st); long t2=t1.getTime(); if (t>t2) return 0; else return 1;
// TODO Auto-generated catch block e.printStackTrace();
The `kygui` method initializes a graphical user interface (GUI) for a management software titled "Phần mềm quản lý thú cưng." It sets the default close operation to exit the application when the window is closed and defines the window's dimensions A content pane with a white background and a black border is created and set as the main display area, while the layout is configured to null, allowing for custom positioning of components.
JMenuBar menuBar = new JMenuBar(); menuBar.setBounds(0, 0, 548, 26); contentPane.add(menuBar);
The code snippet creates a new disabled menu titled "Hệ thống" using the JMenu class It sets the font to Segoe UI, size 15, and applies a black color for the text while ensuring the background matches the button's default color This menu is then added to the menu bar.
JMenu mnNewMenu_1 = new JMenu("Ch\u1EE9c n\u0103ng"); mnNewMenu_1.addMouseListener(new MouseAdapter() {
@Override public void mouseClicked(MouseEvent e) { hoadon hd=new hoadon(); hd.setVisible(true);
}); mnNewMenu_1.setFont(new Font("Segoe UI", Font.BOLD, 15));
29 mnNewMenu_1.setBackground(new Color(255, 160, 122)); mnNewMenu_1.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_1);
JMenu mnNewMenu_2 = new JMenu("Nh\u00E2n s\u1EF1"); mnNewMenu_2.setEnabled(false); mnNewMenu_2.addMouseListener(new MouseAdapter() {
@Override public void mouseClicked(MouseEvent e) { nhanvien nv = new nhanvien(); nv.setVisible(true);
}); mnNewMenu_2.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_2.setBackground(new Color(0, 206, 209)); mnNewMenu_2.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_2);
JMenu mnNewMenu_3 = new JMenu("H\u00E0ng h\u00F3a"); mnNewMenu_3.setEnabled(false); mnNewMenu_3.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_3.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_3);
JMenu mnNewMenu_4 = new JMenu("Kh\u00E1ch h\u00E0ng"); mnNewMenu_4.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_4.setEnabled(false); mnNewMenu_4.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_4);
JMenu mnNewMenu_5 = new JMenu("B\u00E1o c\u00E1o"); mnNewMenu_5.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_5.setEnabled(false); mnNewMenu_5.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_5);
JMenu mnNewMenu_6 = new JMenu("Gi\u00FAp \u0111\u1EE1"); mnNewMenu_6.setFont(new Font("Segoe UI", Font.PLAIN, 15)); mnNewMenu_6.setEnabled(false); mnNewMenu_6.setForeground(new Color(0, 0, 0)); menuBar.add(mnNewMenu_6);
JLabel lblNewLabel = new JLabel("B\u00E1n h\u00E0ng"); lblNewLabel.setBounds(49, 70, 77, 20); lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblNewLabel);
JLabel lblBnHng = new JLabel("D\u1ECBch v\u1EE5"); lblBnHng.setBounds(149, 70, 77, 20); lblBnHng.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblBnHng);
JLabel lblHan = new JLabel("H\u00F3a \u0111\u01A1n"); lblHan.setBounds(255, 70, 77, 20); lblHan.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblHan);
JLabel lblKGi = new JLabel("K\u00FD g\u1EEDi"); lblKGi.setBounds(368, 70, 77, 20); lblKGi.setForeground(Color.CYAN); lblKGi.setBackground(Color.CYAN); lblKGi.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblKGi);
JLabel lblngKThng = new JLabel("\u0110\u0103ng k\u00FD th\u00F4ng tin"); lblngKThng.setBounds(455, 70, 121, 20); lblngKThng.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblngKThng);
JLabel kg1 = new JLabel(""); kg1.setBounds(52, 36, 45, 32); contentPane.add(kg1);
JLabel kg2 = new JLabel(""); kg2.setBounds(152, 36, 45, 32); contentPane.add(kg2);
JLabel kg3 = new JLabel(""); kg3.setBounds(265, 36, 45, 32); contentPane.add(kg3);
JLabel kg4 = new JLabel(""); kg4.setBounds(364, 36, 45, 32); contentPane.add(kg4);
JLabel kg5 = new JLabel(""); kg5.setBounds(485, 36, 45, 32); contentPane.add(kg5);
ImageIcon icon1= new ImageIcon("d:/java/kg1.png"); kg1.setIcon(icon1);
ImageIcon icon2= new ImageIcon("d:/java/kg2.png"); kg2.setIcon(icon2);
ImageIcon icon3= new ImageIcon("d:/java/kg3.png"); kg3.setIcon(icon3);
ImageIcon icon4= new ImageIcon("d:/java/kg4.png"); kg4.setIcon(icon4);
ImageIcon icon5= new ImageIcon("d:/java/kg5.png"); kg5.setIcon(icon5);
JButton btnNewButton = new JButton(""); btnNewButton.setBounds(10, 100, 626, 3); btnNewButton.setBackground(SystemColor.desktop); contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton(""); btnNewButton_1.setBounds(12, 106, 3, 399); btnNewButton_1.setBackground(SystemColor.desktop); contentPane.add(btnNewButton_1);
JButton btnNewButton_1_1 = new JButton(""); btnNewButton_1_1.setBounds(630, 106, 3, 399); btnNewButton_1_1.setBackground(SystemColor.desktop); contentPane.add(btnNewButton_1_1);
JButton btnNewButton_2 = new JButton(""); btnNewButton_2.setBounds(10, 502, 626, 3); btnNewButton_2.setBackground(Color.BLACK); contentPane.add(btnNewButton_2);
The code snippet creates a new button, `btnNewButton_3`, and sets its dimensions and background color before adding it to the content pane Additionally, it initializes a text field, `txtHThngK`, with specific bounds, center alignment, a white background, and a font style of "Tahoma" at size 16, displaying the text "Hệ thống ký gửi." This text field is also added to the content pane and configured to hold 10 columns Furthermore, another text field, `txtChungangS`, is created with defined dimensions and center alignment, ready to be integrated into the user interface.
32 txtChungangS.setFont(new Font("Tahoma", Font.PLAIN, 14)); txtChungangS.setText("Chu\u1ED3ng \u0111ang s\u1EED d\u1EE5ng"); contentPane.add(txtChungangS); txtChungangS.setColumns(10);
The JComboBox component is created with a white background and positioned at coordinates (236, 159) with a size of 91 by 21 pixels It is added to the content pane and populated with items labeled "chuồng 01" through "chuồng 15" This setup allows users to select from a variety of options within the combo box.
JLabel kg6 = new JLabel(""); kg6.setBounds(20, 113, 38, 37); contentPane.add(kg6);
ImageIcon icon6= new ImageIcon("d:/java/kg6.png"); kg6.setIcon(icon6);
JLabel lblNewLabel_3 = new JLabel("C\u00F2n \u0111ang tr\u1ED1ng"); lblNewLabel_3.setBounds(13, 533, 113, 20); lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 14)); contentPane.add(lblNewLabel_3);
JLabel chuong = new JLabel(""); chuong.setBounds(152, 515, 63, 52); contentPane.add(chuong);
ImageIcon icon9= new ImageIcon("d:/java/chuong1.png"); chuong.setIcon(icon9);
JLabel lblNewLabel_4 = new JLabel(" \u0110ang \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng"); lblNewLabel_4.setBounds(306, 533, 151, 20); lblNewLabel_4.setForeground(Color.MAGENTA); lblNewLabel_4.setBackground(Color.WHITE); lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblNewLabel_4);
JLabel chuong_1 = new JLabel(""); chuong_1.setBounds(467, 515, 63, 61); contentPane.add(chuong_1);
ImageIcon icon10= new ImageIcon("d:/java/chuong2.png"); chuong_1.setIcon(icon10);
JLabel lblNewLabel_5 = new JLabel("Chu\u1ED3ng"); lblNewLabel_5.setBounds(149, 574, 63, 20); lblNewLabel_5.setHorizontalAlignment(SwingConstants.CENTER); lblNewLabel_5.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblNewLabel_5);
JLabel lblNewLabel_6 = new JLabel("Chu\u1ED3ng (^^)"); lblNewLabel_6.setBounds(455, 579, 93, 20); lblNewLabel_6.setForeground(Color.MAGENTA); lblNewLabel_6.setBackground(Color.WHITE); lblNewLabel_6.setFont(new Font("Tahoma", Font.PLAIN, 15)); contentPane.add(lblNewLabel_6);
JLabel c01 = new JLabel(""); c01.setBounds(42, 201, 63, 52); contentPane.add(c01); c01.setIcon(icon9);
JLabel c02 = new JLabel(""); c02.setBounds(162, 201, 63, 52); contentPane.add(c02); c02.setIcon(icon9);
JLabel c03 = new JLabel(""); c03.setBounds(282, 201, 63, 52); contentPane.add(c03); c03.setIcon(icon9);
JLabel c04 = new JLabel(""); c04.setBounds(402, 201, 63, 52); contentPane.add(c04); c04.setIcon(icon9);
34 c05.setBounds(522, 201, 63, 52); contentPane.add(c05); c05.setIcon(icon9);
JLabel c06 = new JLabel(""); c06.setBounds(42, 301, 63, 52); contentPane.add(c06); c06.setIcon(icon9);
JLabel c07 = new JLabel(""); c07.setBounds(162, 301, 63, 52); contentPane.add(c07); c07.setIcon(icon9);
JLabel c08 = new JLabel(""); c08.setBounds(282, 301, 63, 52); contentPane.add(c08); c08.setIcon(icon9);
JLabel c09 = new JLabel(""); c09.setBounds(402, 301, 63, 52); contentPane.add(c09); c09.setIcon(icon9);
JLabel c10 = new JLabel(""); c10.setBounds(522, 301, 63, 52); contentPane.add(c10); c10.setIcon(icon9);
JLabel c11 = new JLabel(""); c11.setBounds(42, 401, 63, 52); contentPane.add(c11); c11.setIcon(icon9);
JLabel c12 = new JLabel(""); c12.setBounds(162, 401, 63, 52); contentPane.add(c12); c12.setIcon(icon9);
JLabel c13 = new JLabel(""); c13.setBounds(282, 401, 63, 52); contentPane.add(c13); c13.setIcon(icon9);
JLabel c14 = new JLabel(""); c14.setBounds(402, 401, 63, 52); contentPane.add(c14); c14.setIcon(icon9);
JLabel c15 = new JLabel(""); c15.setBounds(522, 401, 63, 52); contentPane.add(c15); c15.setIcon(icon9);
JLabel s1 = new JLabel("Chu\u1ED3ng 01"); s1.setBounds(42, 263, 77, 20); s1.setFont(new Font("Tahoma", Font.BOLD, 13));
JLabel s2 = new JLabel("Chu\u1ED3ng 02"); s2.setBounds(160, 263, 77, 20); s2.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s2);
JLabel s3 = new JLabel("Chu\u1ED3ng 03"); s3.setBounds(281, 263, 77, 20); s3.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s3);
JLabel s4 = new JLabel("Chu\u1ED3ng 04"); s4.setBounds(400, 263, 77, 20); s4.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s4);
JLabel s5 = new JLabel("Chu\u1ED3ng 05"); s5.setBounds(524, 263, 77, 20); s5.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s5);
JLabel s6 = new JLabel("Chu\u1ED3ng 06"); s6.setBounds(42, 363, 77, 20); s6.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s6);
JLabel s7 = new JLabel("Chu\u1ED3ng 07"); s7.setBounds(160, 363, 77, 20); s7.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s7);
JLabel s8 = new JLabel("Chu\u1ED3ng 08"); s8.setBounds(281, 363, 77, 20); s8.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s8);
JLabel s9 = new JLabel("Chu\u1ED3ng 09"); s9.setBounds(402, 363, 77, 20); s9.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s9);
JLabel s10 = new JLabel("Chu\u1ED3ng 10"); s10.setBounds(524, 363, 77, 20); s10.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s10);
JLabel s11 = new JLabel("Chu\u1ED3ng 11"); s11.setBounds(42, 463, 77, 20); s11.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s11);
JLabel s12 = new JLabel("Chu\u1ED3ng 12"); s12.setBounds(149, 463, 77, 20); s12.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s12);
JLabel s13 = new JLabel("Chu\u1ED3ng 13"); s13.setBounds(281, 463, 77, 20); s13.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s13);
JLabel s14 = new JLabel("Chu\u1ED3ng 14"); s14.setBounds(400, 463, 77, 20); s14.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s14);
JLabel s15 = new JLabel("Chu\u1ED3ng 15"); s15.setBounds(524, 463, 77, 20); s15.setFont(new Font("Tahoma", Font.BOLD, 13)); contentPane.add(s15);
JPanel panel = new JPanel(); panel.setBounds(646, 100, 519, 455); panel.setBackground(Color.YELLOW); panel.setForeground(Color.BLACK); contentPane.add(panel); panel.setLayout(null);
JLabel lblNewLabel_7 = new JLabel("Th\u00F4ng tin k\u00FD g\u1EEDi"); lblNewLabel_7.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblNewLabel_7.setBounds(24, 1, 106, 19); panel.add(lblNewLabel_7);
JButton btnNewButton_4 = new JButton(""); btnNewButton_4.setBackground(Color.BLACK); btnNewButton_4.setBounds(140, 10, 379, 3); panel.add(btnNewButton_4);
JButton btnNewButton_5 = new JButton(""); btnNewButton_5.setBackground(Color.BLACK);
37 btnNewButton_5.setBounds(0, 1, 3, 445); panel.add(btnNewButton_5);
JButton btnNewButton_6 = new JButton(""); btnNewButton_6.setBackground(Color.BLACK); btnNewButton_6.setBounds(0, 452, 519, 3); panel.add(btnNewButton_6);
JButton btnNewButton_7 = new JButton(""); btnNewButton_7.setBackground(Color.BLACK); btnNewButton_7.setBounds(516, 16, 3, 432); panel.add(btnNewButton_7);
JLabel lblNewLabel_8 = new JLabel("M\u00E3 k\u00FD g\u1EEDi"); lblNewLabel_8.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8.setBounds(24, 47, 81, 19); panel.add(lblNewLabel_8);
JLabel lblNewLabel_8_1 = new JLabel("T\u00EAn ch\u1EE7"); lblNewLabel_8_1.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_1.setBounds(234, 47, 81, 19); panel.add(lblNewLabel_8_1);
JLabel lblNewLabel_8_2 = new JLabel("Li\u00EAn h\u1EC7"); lblNewLabel_8_2.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_2.setBounds(425, 52, 81, 19); panel.add(lblNewLabel_8_2);
JLabel lblNewLabel_8_3 = new JLabel("CMND"); lblNewLabel_8_3.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_3.setBounds(24, 130, 81, 19); panel.add(lblNewLabel_8_3);
JLabel lblNewLabel_8_4 = new JLabel("Ng\u00E0y g\u1EEDi"); lblNewLabel_8_4.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_4.setBounds(24, 220, 81, 19); panel.add(lblNewLabel_8_4);
JLabel lblNewLabel_8_5 = new JLabel("M\u00E3 nh\u00E2n vi\u00EAn"); lblNewLabel_8_5.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_5.setBounds(24, 311, 106, 19); panel.add(lblNewLabel_8_5);
JLabel lblNewLabel_8_6 = new JLabel("T\u00EAn pet"); lblNewLabel_8_6.setFont(new Font("Tahoma", Font.PLAIN, 15));
38 lblNewLabel_8_6.setBounds(234, 135, 81, 19); panel.add(lblNewLabel_8_6);
JLabel lblNewLabel_8_7 = new JLabel("Ng\u00E0y tr\u1EA3"); lblNewLabel_8_7.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_7.setBounds(234, 220, 81, 19); panel.add(lblNewLabel_8_7);
JLabel lblNewLabel_8_8 = new JLabel("S\u1ED1 l\u01B0\u1EE3ng"); lblNewLabel_8_8.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_8.setBounds(425, 135, 81, 19); panel.add(lblNewLabel_8_8);
JLabel lblNewLabel_8_9 = new JLabel("Gi\u00E1 combo"); lblNewLabel_8_9.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_9.setBounds(425, 225, 81, 19); panel.add(lblNewLabel_8_9);
JLabel lblNewLabel_8_10 = new JLabel("T\u00EAn chu\u1ED3ng"); lblNewLabel_8_10.setFont(new Font("Tahoma", Font.PLAIN, 15)); lblNewLabel_8_10.setBounds(234, 311, 81, 19); panel.add(lblNewLabel_8_10);
In the user interface code, a JLabel labeled "Giấy tờ" is created with a Tahoma font at a size of 15, positioned at coordinates (425, 311) on the panel Additionally, four JTextFields are added to the panel, each configured with a width of 106 pixels and a height of 24 pixels The first JTextField is positioned at (9, 76), the second at (209, 76), the third at (400, 76), and the fourth at (9, 160), all with a column count of 10 to accommodate user input effectively.
In the user interface design, several JTextFields are added to the panel, each configured with a specific column size and position The JTextField instances include textField_4, textField_6, textField_7, textField_8, textField_9, and textField_11, with dimensions set to 106 pixels in width and varying vertical positions This setup enhances user interaction by providing multiple input fields for data entry, ensuring a streamlined and organized layout.
ActionListener() { public void actionPerformed(ActionEvent e) { if (p==1)
String[] s=comboBox.getSelectedItem().toString().split("[ ]"); int t= Integer.parseInt(s[1]); a.remove(c[t]); b[t]=0;
The code snippet provided sets icons and text colors based on the value of the variable 't', where each condition corresponds to a specific component (c01 to c15) and its associated label (s1 to s15) When 't' matches a specific number, the corresponding component's icon is updated to 'icon9', and its text color is changed to black Additionally, the code resets multiple text fields (textField, textField_1, textField_2, etc.) to empty strings, effectively clearing any previous input This structured approach enhances user interface responsiveness and maintains clarity in the application's visual elements.
JOptionPane.showMessageDialog(btnNewButton_8," Chưa nhập thông tin cần xóa");
}); btnNewButton_8.setBackground(Color.WHITE); btnNewButton_8.setFont(new Font("Tahoma",
41 btnNewButton_8.setBounds(20, 406, 65, 24); panel.add(btnNewButton_8);
JComboBox comboBox_1 = new JComboBox(); comboBox_1.setBackground(Color.WHITE); comboBox_1.setBounds(425, 164, 57, 21); panel.add(comboBox_1); comboBox_1.addItem("1"); comboBox_1.addItem("2"); comboBox_1.addItem("3"); comboBox_1.addItem("4");
JComboBox comboBox_2 = new JComboBox(); comboBox_2.setBackground(Color.WHITE); comboBox_2.setBounds(244, 340, 43, 21); panel.add(comboBox_2); nhapdulieusql(); for (int j=0;j