项目代码及其相关配置文件链接:https://pan.baidu.com/s/1smZS4OX 密码:c37f
一,功能
(1)用户登录注册
(2)人员基本信息的增删改查和统计部门人数以及总人数
(3)工资信息的增删改查和统计部门工资以及总工资
二,工具
(1)java编程:Eclipse Java EE IDE
(2)数据库:SQL Server2008 R2
(3)jdbc:sqljdbc4.jar
三,效果展示
(1)注册
(2)登录
(3)主界面
(4)查找
四,包结构
五,数据库设计
(1)表结构
(2)各表字段
1>BaseInfo_Table表
2>Password_Table表
3>Manager表
4>SalesManager表
5>Technician表
6>Salesperson表
六,系统UML图介绍
(1)用例图
(2)注册类图
(3)注册时序图
七,系统数据流程图
八,主要操作代码
package info;
import java.awt.BorderLayout;
public class Info2 extends JFrame {
/**
*
*/
private static final long serialVersionUID = -1207187762843890725L;
private JMenuBar jBar;
private JMenu jMenu1,jMenu2,jMenu3,jMenu4,jMenu5,jMenu_introduce;
private JMenuItem jMenuItem1,jMenuItem2,jMenuItem3,jMenuItem4,jMenuItem6,jMenuItem7,jMenuItem8,jMenuItem9,jmenuItem_introduce;
private JPanel contentPane;
private JPanel panel_1,panel_1_0,panel_2,panel_2_0,panel_3,panel_4,panel_4_0,panel_5,panel_5_0,panel_6,panel_7;
private CardLayout cardLayout,cLayout;
private JButton btn_confirm,btn_cancel;
private JLabel label_id,label_sex,label_name,label_birthday,label_phone;
private JTextField textField_id,textField_name,textField_birthday,textField_phone;//输入文本框
private JLabel label_id_hint,label_birthday_hint,label_sex_hint,label_name_hint;//提示信息标签
private JLabel label_addBasePanel_hint,label_addSalaryPanel_hint;//面板区分信息标签
private JComboBox comboBox_admin,comboBox_2,comboBox_sex,comboBox_count,comboBox_id_Salary;
private JLabel label_deleteBasePanel_hint;
private JLabel label_15;
private JLabel lblNewLabel_3;
private JLabel label_16;
private JLabel label_17;
private JLabel lblNewLabel_4;
private JTextField textField_8;
private JButton btn_both,btn_strictfp,btn_clear;//全部查询,精确查询
private JScrollPane scrollPane;
private JTable select_table;
private Object[][] empty= new Object[100][6],all_Data=new Object[100][6],sec_Data = new Object[100][6],delete_old_data=new Object[1][6];
private Object[][] repairBase_old=new Object[1][6],select_salary_strictfp=new Object[100][7];
private Object[][] repairSalary_old=new Object[1][7],selectSalary=new Object[100][7],selectEmpty=new Object[100][7];
private Boolean bool=null;//性别的布尔值
private JTextField textField_deleteBase;
private JTable table_delete_repair;
private JLabel label_repair;
private JTextField textField_repairBase;
private JTable table_repairBase_old;
private JLabel label_5;
private JTextField textField_select_identity;
private JButton button_select_strictfp;
private JButton button_select_both;
private JScrollPane scrollPane_1,scrollPane_repairBase_old,scrollPane_repairSalary_old;
private JTable table_select_Salary;
private JButton button_wipe;
private JTextField textField_addSalary;
private JPanel panel_base;
private JPanel panel_00,panel_01,panel_02,panel_03,panel_04;
private JLabel label_1;
private JTextField textField_Manager;
private JLabel label_6;
private JTextField textField_Technician_hourRate;
private JLabel label_7;
private JTextField textField_Technician_workHours;
private JLabel label_8;
private JTextField textField_SalesManager_BasePay;
private JLabel label_9;
private JTextField textField_SalesManager_pushMoney;
private JLabel label_10;
private JLabel label_11;
private JTextField textField_SalesManager_sales;
private JLabel label_12;
private JTextField textField_Salesperson_sales;
private JLabel label_13;
private JTextField textField_Salesperson_pushMoney;
private JLabel label_18;
private JButton button_Manager_add;
private JButton button_Technician_add;
private JButton button_SalesManager_add;
private JButton button_Salesperson_add;
private JLabel label_19;
private JButton button_addSalary_confirm;
private JButton button_addSalary_canel;
private JButton button_delete;
private JButton button_delCanel;
private JButton button_repairBase_confirm,button_repairBase_cancel;//修改基本信息的查找确认、查找取消、修改确认按钮
private JButton button_repair_confirm,button_repair_canel;//修改工资信息的确认和取消按钮
private JTextField textField_repairSalary;
private JLabel lblNewLabel_1;
private JTable table_repairSalary_old;
private String number;
private JLabel label_3;
private JMenu jmenu6;
private JMenuItem menuItem_countPeople;
private JLabel label_20;
private JLabel label_23;
private JTextField textField_manager_countPeople;
private JTextField textField_SalesManager_countPeople;
private JTextField textField_Technician_countPeople;
private JTextField textField_Salesperson_countPeople;
private JLabel label_25;
private JTextField textField_both_countPeople;
private JLabel label_26;
private JButton button_countSalary;
private JLabel label_27;
private JTextField textField_Manage_Salary;
private JLabel label_28;
private JTextField textField_SalesManager_Salary;
private JLabel label_29;
private JTextField textField_Technician_Salary;
private JLabel label_30;
private JTextField textField_Salesperson_Salary;
private JLabel label_31;
private JTextField textField_bothSalary;
private JButton button_wipe_SalaryCount;
/**
* Launch the application.
*/
/**
* Create the frame.
*/
public Info2() {
setResizable(false);
setTitle("操作窗口");
jBar=new JMenuBar();
jMenu1=new JMenu("基本数据维护");
jMenu_introduce=new JMenu("系统介绍");
jMenu_introduce.setIcon(new ImageIcon(Info2.class.getResource("/images/bookTypeManager.png")));
jMenu1.setIcon(new ImageIcon(Info2.class.getResource("/images/base.png")));
jMenuItem1=new JMenuItem("关于我们");
jMenuItem1.setIcon(new ImageIcon(Info2.class.getResource("/images/about.png")));
jMenu2=new JMenu("增加");
jMenu2.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
jMenu3=new JMenu("删除");
jMenu3.setIcon(new ImageIcon(Info2.class.getResource("/images/delete.png")));
jMenu4=new JMenu("修改");
jMenu4.setIcon(new ImageIcon(Info2.class.getResource("/images/modify.png")));
jMenu5=new JMenu("查找");
jMenu5.setIcon(new ImageIcon(Info2.class.getResource("/images/search.png")));
jMenuItem2=new JMenuItem("基本信息");
jMenuItem3=new JMenuItem("工资信息");
jMenuItem4=new JMenuItem("基本和工资信息");
jMenuItem6=new JMenuItem("基本信息");
jMenuItem7=new JMenuItem("工资信息");
jMenuItem8=new JMenuItem("基本信息");
jMenuItem9=new JMenuItem("工资信息");
jBar.setFont(new Font("宋体", Font.PLAIN, 12));
jMenu1.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem1.setFont(new Font("宋体", Font.PLAIN, 12));
jMenu2.setFont(new Font("宋体", Font.PLAIN, 12));
jMenu3.setFont(new Font("宋体", Font.PLAIN, 12));
jMenu4.setFont(new Font("宋体", Font.PLAIN, 12));
jMenu5.setFont(new Font("宋体", Font.PLAIN, 12));
jMenu_introduce.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem2.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem3.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem4.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem6.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem7.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem8.setFont(new Font("宋体", Font.PLAIN, 12));
jMenuItem9.setFont(new Font("宋体", Font.PLAIN, 12));
setJMenuBar(jBar);
jBar.add(jMenu1);
jmenuItem_introduce = new JMenuItem("\u7CFB\u7EDF\u7B80\u4ECB");
jmenuItem_introduce.setIcon(new ImageIcon(Info2.class.getResource("/images/me.png")));
jmenuItem_introduce.setFont(new Font("宋体", Font.PLAIN, 12));
jBar.add(jMenu_introduce);
jMenu_introduce.add(jmenuItem_introduce);
jMenu_introduce.add(jMenuItem1);
jMenu1.add(jMenu2);//增
//jMenu1.addSeparator();//添加分割线
jMenu1.add(jMenu3);//删
jMenu1.add(jMenu4);//改
jMenu1.add(jMenu5);//查
jMenu2.add(jMenuItem2);//增加基本信息
jMenu2.add(jMenuItem3);//增加工资信息
jMenu3.add(jMenuItem4);//删除基本信息
jMenu4.add(jMenuItem6);//修改基本信息
jMenu4.add(jMenuItem7);//修改工资信息
jMenu5.add(jMenuItem8);//查找基本信息
jMenu5.add(jMenuItem9);//查找工资信息
jmenu6 = new JMenu("\u7EDF\u8BA1");//统计
jmenu6.setFont(new Font("宋体", Font.PLAIN, 12));
jmenu6.setIcon(new ImageIcon(Info2.class.getResource("/images/bookManager.png")));
jMenu1.add(jmenu6);
menuItem_countPeople = new JMenuItem("\u7EDF\u8BA1\u90E8\u95E8\u4EBA\u6570");
menuItem_countPeople.setFont(new Font("宋体", Font.PLAIN, 12));
jmenu6.add(menuItem_countPeople);
JMenuItem menuItem_countSalary = new JMenuItem("\u7EDF\u8BA1\u90E8\u95E8\u603B\u5DE5\u8D44");
menuItem_countSalary.setFont(new Font("宋体", Font.PLAIN, 12));
jmenu6.add(menuItem_countSalary);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 635, 358);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));//创建为水平间隙和垂直间隙都为0的边界式布局
panel_1 = new JPanel();//卡片式布局的基层
contentPane.add(panel_1, BorderLayout.CENTER);//中间容器为边界式布局
cardLayout=new CardLayout(0, 0);//创建为水平间隙和垂直间隙都为0的卡片式布局
panel_1.setLayout(cardLayout);//卡片式布局
ImageIcon bg=new ImageIcon(Info2.class.getResource("/images/巧办网_商务合作banner背景模板PSD分层.png"));
JLabel jLabel_bg=new JLabel(bg);
jLabel_bg.setSize(bg.getIconWidth(),bg.getIconHeight());
JPanel jPanel=new JPanel();
jPanel=(JPanel)this.getContentPane();
jPanel.setOpaque(false);
getLayeredPane().add(jLabel_bg,new Integer(Integer.MIN_VALUE));
panel_1_0=new JPanel();//主页面板
panel_1_0.setLayout(null);
panel_1_0.setOpaque(false);
panel_1.add(panel_1_0);
panel_1.setOpaque(false);
label_3 = new JLabel("\u5C0F\u578B\u516C\u53F8\u5DE5\u8D44\u7BA1\u7406\u7CFB\u7EDF",JLabel.CENTER);
label_3.setFont(new Font("宋体", Font.BOLD | Font.ITALIC, 30));
label_3.setForeground(Color.GRAY);
label_3.setBackground(Color.WHITE);
label_3.setBounds(0, 0, 619, 47);
panel_1_0.add(label_3);
/*增加模块 */
panel_2 = new JPanel();//增加基本信息面板
panel_2_0=new JPanel();//增加工资信息面板
panel_2.setLayout(null);
panel_2_0.setLayout(null);
panel_1.add(panel_2, "增加基本");
panel_1.add(panel_2_0,"增加工资");
label_id= new JLabel("职工编号");
label_id.setBounds(83, 30, 60, 15);
panel_2.add(label_id);
label_name= new JLabel("\u59D3 \u540D");
label_name.setBounds(83, 65, 60, 21);
panel_2.add(label_name);
label_sex=new JLabel("\u6027 \u522B");
label_sex.setBounds(83, 100, 54, 15);
panel_2.add(label_sex);
label_birthday= new JLabel("出生日期");
label_birthday.setBounds(83, 140, 54, 15);
panel_2.add(label_birthday);
label_phone = new JLabel("联系电话");
label_phone.setBounds(83, 170, 54, 15);
panel_2.add(label_phone);
textField_id= new JTextField();//职工编号文本框
textField_id.setBounds(166, 30, 196, 21);
panel_2.add(textField_id);
textField_id.setColumns(10);
textField_name = new JTextField();//姓名信息输入文本框
textField_name.setBounds(166, 65, 196, 21);
panel_2.add(textField_name);
textField_name.setColumns(10);
comboBox_sex=new JComboBox();//性别信息选择框
comboBox_sex.setModel(new DefaultComboBoxModel(new String[] {"请选择性别","男", "女"}));
comboBox_sex.setBounds(166, 100, 196, 21);
panel_2.add(comboBox_sex);
textField_birthday= new JTextField();//出生日期输入文本框
textField_birthday.setBounds(166, 137, 196, 21);
panel_2.add(textField_birthday);
textField_birthday.setColumns(10);
textField_phone= new JTextField();//联系电话输入文本框
textField_phone.setBounds(166, 170, 196, 21);
panel_2.add(textField_phone);
textField_phone.setColumns(10);
label_id_hint= new JLabel("*必填*");//职工编号提示标签
label_id_hint.setBounds(396, 30, 54, 15);
label_id_hint.setForeground(Color.RED);
label_id_hint.setFont(new Font("宋体",Font.PLAIN,14));
panel_2.add(label_id_hint);
label_name_hint= new JLabel("*必填*");//姓名信息提示标签
label_name_hint.setBounds(396, 65, 54, 15);
label_name_hint.setForeground(Color.RED);
label_name_hint.setFont(new Font("宋体",Font.PLAIN,14));
panel_2.add(label_name_hint);
label_sex_hint=new JLabel("*必填*");//性别信息提示标签
label_sex_hint.setBounds(396,100, 54, 15);
label_sex_hint.setForeground(Color.RED);
label_sex_hint.setFont(new Font("宋体",Font.PLAIN,14));
panel_2.add(label_sex_hint);
label_birthday_hint=new JLabel("*不为空且格式为(xxxx-xx-xx)*");//出生日期信息提示标签
label_birthday_hint.setBounds(396,137, 200, 15);
label_birthday_hint.setForeground(Color.RED);
label_birthday_hint.setFont(new Font("宋体",Font.PLAIN,14));
panel_2.add(label_birthday_hint);
comboBox_admin= new JComboBox();//增加基本信息的身份选择
comboBox_admin.setModel(new DefaultComboBoxModel(new String[] {"请选择身份···", "经理", "销售经理","技术人员","销售人员"}));
comboBox_admin.setBounds(166, 210, 108, 21);
panel_2.add(comboBox_admin);
btn_confirm=new JButton("\u589E\u52A0");//确认添加基本信息
btn_confirm.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
btn_confirm.setBounds(166,245,95,25);
panel_2.add(btn_confirm);
btn_cancel=new JButton("取消");//清空文本输入框基本信息
btn_cancel.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
btn_cancel.setBounds(270,245,95,25);
panel_2.add(btn_cancel);
label_addBasePanel_hint= new JLabel("增加基本信息");//面板区分提示信息
label_addBasePanel_hint.setBounds(508, 0, 82, 15);
panel_2.add(label_addBasePanel_hint);
label_addSalaryPanel_hint= new JLabel("增加工资信息");//面板区分提示信息
label_addSalaryPanel_hint.setBounds(508, 0, 82, 15);
panel_2_0.add(label_addSalaryPanel_hint);
JLabel label = new JLabel("\u8BF7\u8F93\u5165\u9700\u8981\u6DFB\u52A0\u5DE5\u8D44\u4FE1\u606F\u7684\u804C\u5DE5\u7F16\u53F7");
label.setBounds(10, 25, 198, 21);
panel_2_0.add(label);
textField_addSalary = new JTextField();
textField_addSalary.setBounds(218, 25, 170, 21);
panel_2_0.add(textField_addSalary);
textField_addSalary.setColumns(10);
button_addSalary_confirm = new JButton("\u6DFB\u52A0");
button_addSalary_confirm.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
button_addSalary_confirm.setBounds(398, 24, 93, 23);
panel_2_0.add(button_addSalary_confirm);
panel_base = new JPanel();
panel_base.setBounds(39, 77, 542, 187);
panel_2_0.add(panel_base);
cLayout=new CardLayout(0, 0);
panel_base.setLayout(cLayout);
panel_00 = new JPanel();
panel_base.add(panel_00, "提示");
panel_00.setLayout(null);
label_19 = new JLabel("\u5DE5\u8D44\u4FE1\u606F\u8F93\u5165\u9762\u677F");
label_19.setBounds(212, 78, 116, 15);
panel_00.add(label_19);
panel_01 = new JPanel();
panel_base.add(panel_01, "经理");
panel_01.setLayout(null);
label_1 = new JLabel("\u5DE5\u8D44");
label_1.setBounds(55, 30, 60, 21);
panel_01.add(label_1);
textField_Manager = new JTextField();
textField_Manager.setBounds(125, 30, 133, 21);
panel_01.add(textField_Manager);
textField_Manager.setColumns(10);
button_Manager_add = new JButton("\u6DFB\u52A0");
button_Manager_add.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
button_Manager_add.setBounds(55, 129, 93, 23);
panel_01.add(button_Manager_add);
panel_02 = new JPanel();
panel_base.add(panel_02, "技术人员");
panel_02.setLayout(null);
label_6 = new JLabel("\u6BCF\u5C0F\u65F6\u916C\u91D1");
label_6.setBounds(56, 31, 88, 15);
panel_02.add(label_6);
textField_Technician_hourRate = new JTextField();
textField_Technician_hourRate.setBounds(181, 28, 155, 21);
panel_02.add(textField_Technician_hourRate);
textField_Technician_hourRate.setColumns(10);
label_7 = new JLabel("\u5DE5\u4F5C\u65F6\u6570");
label_7.setBounds(56, 76, 54, 15);
panel_02.add(label_7);
textField_Technician_workHours = new JTextField();
textField_Technician_workHours.setBounds(181, 73, 155, 21);
panel_02.add(textField_Technician_workHours);
textField_Technician_workHours.setColumns(10);
button_Technician_add = new JButton("\u6DFB\u52A0");
button_Technician_add.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
button_Technician_add.setBounds(56, 143, 93, 23);
panel_02.add(button_Technician_add);
panel_03 = new JPanel();
panel_base.add(panel_03, "销售经理");
panel_03.setLayout(null);
panel_04 = new JPanel();
panel_base.add(panel_04, "销售人员");
panel_04.setLayout(null);
label_12 = new JLabel("\u9500\u552E\u989D");
label_12.setBounds(69, 39, 54, 15);
panel_04.add(label_12);
textField_Salesperson_sales = new JTextField();
textField_Salesperson_sales.setBounds(146, 36, 170, 21);
panel_04.add(textField_Salesperson_sales);
textField_Salesperson_sales.setColumns(10);
label_13 = new JLabel("\u63D0\u6210");
label_13.setBounds(69, 88, 54, 15);
panel_04.add(label_13);
textField_Salesperson_pushMoney = new JTextField();
textField_Salesperson_pushMoney.setBounds(146, 85, 170, 21);
panel_04.add(textField_Salesperson_pushMoney);
textField_Salesperson_pushMoney.setColumns(10);
label_18 = new JLabel("0~1\u4E4B\u95F4");
label_18.setForeground(Color.RED);
label_18.setBounds(354, 85, 54, 21);
panel_04.add(label_18);
button_Salesperson_add = new JButton("\u6DFB\u52A0");
button_Salesperson_add.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
button_Salesperson_add.setBounds(69, 140, 93, 23);
panel_04.add(button_Salesperson_add);
label_8 = new JLabel("\u57FA\u672C\u5DE5\u8D44");
label_8.setBounds(69, 35, 54, 18);
panel_03.add(label_8);
textField_SalesManager_BasePay = new JTextField();
textField_SalesManager_BasePay.setBounds(153, 35, 161, 21);
panel_03.add(textField_SalesManager_BasePay);
textField_SalesManager_BasePay.setColumns(10);
label_9 = new JLabel("\u63D0 \u6210");
label_9.setBounds(69, 77, 54, 15);
panel_03.add(label_9);
textField_SalesManager_pushMoney = new JTextField();
textField_SalesManager_pushMoney.setBounds(153, 74, 161, 21);
panel_03.add(textField_SalesManager_pushMoney);
textField_SalesManager_pushMoney.setColumns(10);
label_10 = new JLabel("0~1\u4E4B\u95F4");
label_10.setForeground(Color.RED);
label_10.setBounds(356, 74, 54, 21);
panel_03.add(label_10);
label_11 = new JLabel("\u9500\u552E\u989D");
label_11.setBounds(69, 118, 54, 15);
panel_03.add(label_11);
textField_SalesManager_sales = new JTextField();
textField_SalesManager_sales.setBounds(153, 115, 161, 21);
panel_03.add(textField_SalesManager_sales);
textField_SalesManager_sales.setColumns(10);
button_SalesManager_add = new JButton("\u6DFB\u52A0");
button_SalesManager_add.setIcon(new ImageIcon(Info2.class.getResource("/images/add.png")));
button_SalesManager_add.setBounds(69, 154, 93, 23);
panel_03.add(button_SalesManager_add);
button_addSalary_canel = new JButton("\u53D6\u6D88");
button_addSalary_canel.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_addSalary_canel.setBounds(501, 24, 93, 23);
panel_2_0.add(button_addSalary_canel);
/* 删除模块 */
panel_3=new JPanel();
panel_3.setLayout(null);
panel_1.add(panel_3,"删除基本");
label_deleteBasePanel_hint = new JLabel("\u5220\u9664\u804C\u5DE5\u4FE1\u606F");
label_deleteBasePanel_hint.setBounds(524, 0, 85, 15);
panel_3.add(label_deleteBasePanel_hint);
JLabel label_delete = new JLabel("\u8BF7\u8F93\u5165\u9700\u8981\u5220\u9664\u7684\u804C\u5DE5\u7F16\u53F7:");
label_delete.setBounds(22, 38, 163, 21);
panel_3.add(label_delete);
textField_deleteBase =new JTextField();
textField_deleteBase.setBounds(195, 38, 143, 21);
panel_3.add(textField_deleteBase);
textField_deleteBase.setColumns(10);
final JScrollPane scrollPane_delete_old = new JScrollPane();
scrollPane_delete_old.setBounds(22, 185, 440, 50);
panel_3.add(scrollPane_delete_old);
final String[] columnNames_delete = {"职工编号","姓名","性别","出生年月","联系电话","职位"}; //列名
table_delete_repair = new JTable(delete_old_data,columnNames_delete);
table_delete_repair.setEnabled(false);//禁止写入
table_delete_repair.getTableHeader().setReorderingAllowed(false);
table_delete_repair.setRowHeight(25);//以像素为单位的行高
scrollPane_delete_old.setViewportView(table_delete_repair);
JLabel lblOldData = new JLabel("Delete data");
lblOldData.setFont(new Font("幼圆", Font.BOLD, 30));
lblOldData.setBounds(151, 125, 187, 37);
panel_3.add(lblOldData);
button_delete = new JButton("\u5220\u9664");
button_delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
button_delete.setIcon(new ImageIcon(Info2.class.getResource("/images/delete.png")));
button_delete.setBounds(348, 37, 84, 23);
panel_3.add(button_delete);
button_delCanel = new JButton("\u53D6\u6D88");
button_delCanel.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_delCanel.setBounds(442, 37, 84, 23);
panel_3.add(button_delCanel);
/* 修改模块 */
panel_4=new JPanel();
panel_4_0=new JPanel();
panel_4.setLayout(null);
panel_4_0.setLayout(null);
panel_1.add(panel_4,"修改基本");
label_15 = new JLabel("修改基本信息");
label_15.setBounds(506, 0, 84, 15);
panel_4.add(label_15);
label_repair = new JLabel("\u8BF7\u8F93\u5165\u9700\u8981\u4FEE\u6539\u7684\u804C\u5DE5\u7F16\u53F7\uFF1A");
label_repair.setFont(new Font("宋体", Font.ITALIC, 14));
label_repair.setBounds(44, 25, 186, 21);
panel_4.add(label_repair);
textField_repairBase = new JTextField();
textField_repairBase.setBounds(240, 25, 131, 21);
panel_4.add(textField_repairBase);
textField_repairBase.setColumns(10);
button_repairBase_confirm = new JButton("\u4FEE\u6539");
button_repairBase_confirm.setIcon(new ImageIcon(Info2.class.getResource("/images/modify.png")));
button_repairBase_confirm.setBounds(381, 24, 93, 23);
panel_4.add(button_repairBase_confirm);
button_repairBase_cancel = new JButton("\u53D6\u6D88");
button_repairBase_cancel.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_repairBase_cancel.setBounds(484, 25, 93, 23);
panel_4.add(button_repairBase_cancel);
JLabel lblNewLabel = new JLabel("old Data");
lblNewLabel.setFont(new Font("幼圆", Font.BOLD, 22));
lblNewLabel.setBounds(200, 125, 119, 21);
panel_4.add(lblNewLabel);
scrollPane_repairBase_old = new JScrollPane();
scrollPane_repairBase_old.setBounds(44, 156, 430, 48);
panel_4.add(scrollPane_repairBase_old);
final String[] columnNames_repairBase_old= {"职工编号","姓名","性别","出生年月","联系电话","职位"}; //列名
table_repairBase_old = new JTable(repairBase_old,columnNames_repairBase_old);
table_repairBase_old.setEnabled(false);//禁止写入
table_repairBase_old.getTableHeader().setReorderingAllowed(false);//禁止表头拖动
table_repairBase_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairBase_old.setViewportView(table_repairBase_old);
panel_1.add(panel_4_0,"修改工资");
lblNewLabel_3 = new JLabel("修改工资信息");
lblNewLabel_3.setBounds(518, 0, 91, 15);
panel_4_0.add(lblNewLabel_3);
JLabel label_2 = new JLabel("\u8BF7\u8F93\u5165\u9700\u8981\u4FEE\u6539\u7684\u804C\u5DE5\u7F16\u53F7");
label_2.setFont(new Font("宋体", Font.ITALIC, 14));
label_2.setBounds(32, 25, 168, 23);
panel_4_0.add(label_2);
button_repair_confirm = new JButton("\u4FEE\u6539");
button_repair_confirm.setIcon(new ImageIcon(Info2.class.getResource("/images/modify.png")));
button_repair_confirm.setBounds(380, 25, 93, 23);
panel_4_0.add(button_repair_confirm);
button_repair_canel = new JButton("\u53D6\u6D88");
button_repair_canel.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_repair_canel.setBounds(483, 25, 93, 23);
panel_4_0.add(button_repair_canel);
textField_repairSalary = new JTextField();
textField_repairSalary.setBounds(210, 26, 160, 21);
panel_4_0.add(textField_repairSalary);
textField_repairSalary.setColumns(10);
lblNewLabel_1 = new JLabel("old data");
lblNewLabel_1.setFont(new Font("宋体", Font.BOLD, 30));
lblNewLabel_1.setBounds(210, 125, 160, 29);
panel_4_0.add(lblNewLabel_1);
scrollPane_repairSalary_old = new JScrollPane();
scrollPane_repairSalary_old.setBounds(44, 168, 464, 50);
panel_4_0.add(scrollPane_repairSalary_old);
final String[] columnNames_repair_Salary= {"职工编号","基本月薪","销售额","提成","每小时酬金","当月工作时数","总工资"}; //列名
table_repairSalary_old =new JTable(repairSalary_old,columnNames_repair_Salary);
table_repairSalary_old.setEnabled(false);
table_repairSalary_old.getTableHeader().setReorderingAllowed(false);
table_repairSalary_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairSalary_old.setViewportView(table_repairSalary_old);
/* 查找模块 */
panel_5=new JPanel();
panel_5_0=new JPanel();
panel_5_0.setLayout(null);
panel_1.add(panel_5,"查找基本");
panel_5.setLayout(null);
label_16 = new JLabel("查找基本信息");
label_16.setFont(new Font("宋体", Font.PLAIN, 12));
label_16.setBounds(518, 0, 72, 15);
panel_5.add(label_16);
lblNewLabel_4 = new JLabel("查找方式");
lblNewLabel_4.setFont(new Font("宋体", Font.PLAIN, 12));
lblNewLabel_4.setBounds(10, 10, 54, 15);
panel_5.add(lblNewLabel_4);
comboBox_2 = new JComboBox();
comboBox_2.setModel(new DefaultComboBoxModel(new String[] {"请选择查询方式···", "按编号查找", "按姓名查找"}));
comboBox_2.setBounds(74, 7, 97, 21);
panel_5.add(comboBox_2);
textField_8 = new JTextField();
textField_8.setBounds(189, 7, 90, 21);
panel_5.add(textField_8);
textField_8.setColumns(10);
btn_strictfp = new JButton("精确查询");
btn_strictfp.setIcon(new ImageIcon(Info2.class.getResource("/images/search.png")));
btn_strictfp.setFont(new Font("宋体", Font.PLAIN, 12));
btn_strictfp.setBounds(289, 6, 104, 23);
//btn_strictfp.setEnabled(false);
panel_5.add(btn_strictfp);
btn_both = new JButton("全部查询");
btn_both.setIcon(new ImageIcon(Info2.class.getResource("/images/search.png")));
btn_both.setFont(new Font("宋体", Font.PLAIN, 12));
btn_both.setBounds(403, 6, 105, 23);
panel_5.add(btn_both);
btn_clear=new JButton("\u6E05\u7A7A\u663E\u793A");
btn_clear.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
btn_clear.setFont(new Font("宋体", Font.PLAIN, 12));
btn_clear.setBounds(500,53,109, 23);
panel_5.add(btn_clear);
scrollPane = new JScrollPane();
scrollPane.setBounds(10, 50, 480, 228);
panel_5.add(scrollPane);
final String[] columnNames = {"职工编号","姓名","性别","出生年月","联系电话","职位"}; //列名
select_table = new JTable(empty,columnNames);
select_table.setEnabled(false);//禁止写入
select_table.getTableHeader().setReorderingAllowed(false);
select_table.setRowHeight(25);//以像素为单位的行高
scrollPane.setViewportView(select_table);
panel_1.add(panel_5_0,"查找工资");
label_17 = new JLabel("查找工资信息");
label_17.setFont(new Font("宋体", Font.PLAIN, 12));
label_17.setBounds(498, 0, 92, 15);
panel_5_0.add(label_17);
label_5 = new JLabel("\u8F93\u5165\u804C\u5DE5\u7F16\u53F7");
label_5.setBounds(10, 43, 92, 15);
panel_5_0.add(label_5);
textField_select_identity = new JTextField();
textField_select_identity.setBounds(112, 40, 153, 21);
panel_5_0.add(textField_select_identity);
textField_select_identity.setColumns(10);
button_select_strictfp = new JButton("\u7CBE\u786E\u67E5\u8BE2");
button_select_strictfp.setFont(new Font("宋体", Font.PLAIN, 12));
button_select_strictfp.setIcon(new ImageIcon(Info2.class.getResource("/images/search.png")));
button_select_strictfp.setBounds(275, 39, 113, 23);
panel_5_0.add(button_select_strictfp);
button_select_both = new JButton("\u5168\u90E8\u67E5\u8BE2");
button_select_both.setFont(new Font("宋体", Font.PLAIN, 12));
button_select_both.setIcon(new ImageIcon(Info2.class.getResource("/images/search.png")));
button_select_both.setBounds(398, 39, 109, 23);
panel_5_0.add(button_select_both);
scrollPane_1 = new JScrollPane();
scrollPane_1.setBounds(10, 87, 486, 185);
panel_5_0.add(scrollPane_1);
final String[] columnNames_select_Salary= {"职工编号","基本月薪","销售额","提成","每小时酬金","当月工作时数","总工资"}; //列名
table_select_Salary = new JTable(selectEmpty,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
scrollPane_1.setViewportView(table_select_Salary);
button_wipe = new JButton("\u6E05\u7A7A\u663E\u793A");
button_wipe.setFont(new Font("宋体", Font.PLAIN, 12));
button_wipe.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_wipe.setBounds(500, 90, 109, 23);
panel_5_0.add(button_wipe);
/* 统计模块*/
panel_6=new JPanel();//统计人数面板
panel_6.setLayout(null);
panel_1.add(panel_6,"统计人数");
JLabel label_4 = new JLabel("\u7EDF\u8BA1\u4EBA\u6570");//统计人数标签标识
label_4.setBounds(555, 10, 54, 15);
panel_6.add(label_4);
label_20 = new JLabel("\u7EDF\u8BA1\u90E8\u95E8\u4EBA\u6570");
label_20.setBounds(105, 23, 80, 21);
panel_6.add(label_20);
comboBox_count = new JComboBox();
comboBox_count.setModel(new DefaultComboBoxModel(new String[] {"\u8BF7\u9009\u62E9\u804C\u4F4D", "\u7ECF\u7406", "\u9500\u552E\u7ECF\u7406", "\u6280\u672F\u4EBA\u5458", "\u9500\u552E\u4EBA\u5458", "\u5168\u90E8"}));
comboBox_count.setBounds(215, 23, 96, 21);
panel_6.add(comboBox_count);
JButton button_count = new JButton("\u786E\u8BA4");
button_count.setIcon(new ImageIcon(Info2.class.getResource("/images/ok.png")));
button_count.setBounds(343, 22, 93, 23);
panel_6.add(button_count);
JLabel label_21 = new JLabel("\u7ECF \u7406");
label_21.setBounds(131, 68, 54, 21);
panel_6.add(label_21);
JLabel label_22 = new JLabel("\u9500\u552E\u7ECF\u7406");
label_22.setBounds(131, 118, 54, 21);
panel_6.add(label_22);
label_23 = new JLabel("\u6280\u672F\u4EBA\u5458");
label_23.setBounds(131, 165, 54, 21);
panel_6.add(label_23);
textField_manager_countPeople = new JTextField();
textField_manager_countPeople.setEditable(false);
textField_manager_countPeople.setBounds(215, 68, 122, 21);
panel_6.add(textField_manager_countPeople);
textField_manager_countPeople.setColumns(10);
textField_SalesManager_countPeople = new JTextField();
textField_SalesManager_countPeople.setEditable(false);
textField_SalesManager_countPeople.setBounds(215, 118, 122, 21);
panel_6.add(textField_SalesManager_countPeople);
textField_SalesManager_countPeople.setColumns(10);
textField_Technician_countPeople = new JTextField();
textField_Technician_countPeople.setEditable(false);
textField_Technician_countPeople.setBounds(215, 165, 122, 21);
panel_6.add(textField_Technician_countPeople);
textField_Technician_countPeople.setColumns(10);
JLabel label_24 = new JLabel("\u9500\u552E\u4EBA\u5458");
label_24.setBounds(131, 212, 54, 15);
panel_6.add(label_24);
textField_Salesperson_countPeople = new JTextField();
textField_Salesperson_countPeople.setEditable(false);
textField_Salesperson_countPeople.setBounds(215, 209, 122, 21);
panel_6.add(textField_Salesperson_countPeople);
textField_Salesperson_countPeople.setColumns(10);
label_25 = new JLabel("\u5168 \u90E8");
label_25.setBounds(131, 256, 54, 15);
panel_6.add(label_25);
textField_both_countPeople = new JTextField();
textField_both_countPeople.setEditable(false);
textField_both_countPeople.setBounds(215, 253, 122, 21);
panel_6.add(textField_both_countPeople);
textField_both_countPeople.setColumns(10);
JButton button_wipe_count = new JButton("\u6E05\u7A7A");
button_wipe_count.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_wipe_count.setBounds(382, 252, 93, 23);
panel_6.add(button_wipe_count);
panel_7=new JPanel();
panel_7.setLayout(null);
panel_1.add(panel_7,"统计工资");
JLabel label_14 = new JLabel("\u7EDF\u8BA1\u5DE5\u8D44");//统计工资标签标识
label_14.setBounds(555, 10, 54, 15);
panel_7.add(label_14);
label_26 = new JLabel("\u7EDF\u8BA1\u5DE5\u8D44");
label_26.setBounds(93, 20, 54, 21);
panel_7.add(label_26);
comboBox_id_Salary = new JComboBox();
comboBox_id_Salary.setModel(new DefaultComboBoxModel(new String[] {"\u8BF7\u9009\u62E9\u804C\u4F4D", "\u7ECF\u7406", "\u9500\u552E\u7ECF\u7406", "\u6280\u672F\u4EBA\u5458", "\u9500\u552E\u4EBA\u5458", "\u5168\u90E8"}));
comboBox_id_Salary.setBounds(192, 20, 87, 21);
panel_7.add(comboBox_id_Salary);
button_countSalary = new JButton("\u786E\u8BA4");
button_countSalary.setIcon(new ImageIcon(Info2.class.getResource("/images/ok.png")));
button_countSalary.setBounds(320, 19, 93, 23);
panel_7.add(button_countSalary);
label_27 = new JLabel("\u7ECF \u7406");
label_27.setBounds(93, 67, 54, 15);
panel_7.add(label_27);
textField_Manage_Salary = new JTextField();
textField_Manage_Salary.setEditable(false);
textField_Manage_Salary.setBounds(192, 64, 105, 21);
panel_7.add(textField_Manage_Salary);
textField_Manage_Salary.setColumns(10);
label_28 = new JLabel("\u9500\u552E\u7ECF\u7406");
label_28.setBounds(93, 114, 54, 15);
panel_7.add(label_28);
textField_SalesManager_Salary = new JTextField();
textField_SalesManager_Salary.setEditable(false);
textField_SalesManager_Salary.setBounds(192, 111, 105, 21);
panel_7.add(textField_SalesManager_Salary);
textField_SalesManager_Salary.setColumns(10);
label_29 = new JLabel("\u6280\u672F\u4EBA\u5458");
label_29.setBounds(93, 159, 54, 15);
panel_7.add(label_29);
textField_Technician_Salary = new JTextField();
textField_Technician_Salary.setEditable(false);
textField_Technician_Salary.setBounds(192, 156, 105, 21);
panel_7.add(textField_Technician_Salary);
textField_Technician_Salary.setColumns(10);
label_30 = new JLabel("\u9500\u552E\u4EBA\u5458");
label_30.setBounds(93, 199, 54, 15);
panel_7.add(label_30);
textField_Salesperson_Salary = new JTextField();
textField_Salesperson_Salary.setEditable(false);
textField_Salesperson_Salary.setBounds(192, 196, 105, 21);
panel_7.add(textField_Salesperson_Salary);
textField_Salesperson_Salary.setColumns(10);
label_31 = new JLabel("\u5168 \u90E8");
label_31.setBounds(93, 250, 54, 15);
panel_7.add(label_31);
textField_bothSalary = new JTextField();
textField_bothSalary.setEditable(false);
textField_bothSalary.setBounds(192, 247, 105, 21);
panel_7.add(textField_bothSalary);
textField_bothSalary.setColumns(10);
button_wipe_SalaryCount = new JButton("\u6E05\u7A7A");
button_wipe_SalaryCount.setIcon(new ImageIcon(Info2.class.getResource("/images/reset.png")));
button_wipe_SalaryCount.setBounds(330, 246, 93, 23);
panel_7.add(button_wipe_SalaryCount);
menuItem_countPeople.addActionListener(new ActionListener() {//统计人数
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
cardLayout.show(panel_1,"统计人数");
}
});
/*统计人数面板中的动作内容*/
button_count.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String choose_id=(String)comboBox_count.getSelectedItem();
if(choose_id.equals("请选择职位")){
JOptionPane.showMessageDialog(null,"请选择职位!","提示信息",JOptionPane.WARNING_MESSAGE);
}
else{
if(choose_id.equals("经理")){
String count_Manager="select count(number) from BaseInfo_Table where id='经理'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_Manager);
if(resultSet.next()){
textField_manager_countPeople.setText(String.valueOf(resultSet.getInt(1))+"人");
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if (choose_id.equals("销售经理")) {
String count_SalesManager="select count(number) from BaseInfo_Table where id='销售经理'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_SalesManager);
if(resultSet.next()){
textField_SalesManager_countPeople.setText(String.valueOf(resultSet.getInt(1))+"人");
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("技术人员")){
String count_Technician="select count(number) from BaseInfo_Table where id='技术人员'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_Technician);
if(resultSet.next()){
textField_Technician_countPeople.setText(String.valueOf(resultSet.getInt(1))+"人");
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("销售人员")){
String count_Salesperson="select count(number) from BaseInfo_Table where id='销售人员'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_Salesperson);
if(resultSet.next()){
textField_Salesperson_countPeople.setText(String.valueOf(resultSet.getInt(1))+"人");
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("全部")){
String count_both="select count(number) from BaseInfo_Table";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_both);
if(resultSet.next()){
textField_both_countPeople.setText(String.valueOf(resultSet.getInt(1))+"人");
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
}
}
});
button_wipe_count.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
textField_manager_countPeople.setText("");
textField_SalesManager_countPeople.setText("");
textField_Technician_countPeople.setText("");
textField_Salesperson_countPeople.setText("");
textField_both_countPeople.setText("");
}
});
/*
*
*
*
*
* */
menuItem_countSalary.addActionListener(new ActionListener() {//统计工资
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
cardLayout.show(panel_1,"统计工资");
}
});
/*统计工资面板中的动作内容*/
button_countSalary.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String choose_id=(String)comboBox_id_Salary.getSelectedItem();
if(choose_id.equals("请选择职位")){
JOptionPane.showMessageDialog(null,"请选择职位!","提示信息",JOptionPane.WARNING_MESSAGE);
}
else{
if(choose_id.equals("经理")){
String count_ManagerSalary="select monthPay from Manager";
float ManagerSalary_sum=0;
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_ManagerSalary);
while(resultSet.next()){
ManagerSalary_sum+=resultSet.getFloat(1);
}
textField_Manage_Salary.setText(String.valueOf(ManagerSalary_sum)+"元");
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("销售经理")){
String count_SalesManagerSalary="select monthPay from SalesManager";
float SalesManagerSalary_sum=0;
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_SalesManagerSalary);
while(resultSet.next()){
SalesManagerSalary_sum+=resultSet.getFloat(1);
}
textField_SalesManager_Salary.setText(String.valueOf(SalesManagerSalary_sum)+"元");
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("技术人员")){
String count_TechnicianSalary="select monthPay from Technician";
float TechnicianSalary_sum=0;
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_TechnicianSalary);
while(resultSet.next()){
TechnicianSalary_sum+=resultSet.getFloat(1);
}
textField_Technician_Salary.setText(String.valueOf(TechnicianSalary_sum)+"元");
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("销售人员")){
String count_SalespersonSalary="select monthPay from Salesperson";
float SalespersonSalary_sum=0;
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_SalespersonSalary);
while(resultSet.next()){
SalespersonSalary_sum+=resultSet.getFloat(1);
}
textField_Salesperson_Salary.setText(String.valueOf(SalespersonSalary_sum)+"元");
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
if(choose_id.equals("全部")){
float monthPay=0;
String count_ManagerSalary="select monthPay from Manager";
String count_SalesManagerSalary="select monthPay from SalesManager";
String count_TechnicianSalary="select monthPay from Technician";
String count_SalespersonSalary="select monthPay from Salesperson";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_ManagerSalary);
while(resultSet.next()){
monthPay+=resultSet.getFloat(1);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_SalesManagerSalary);
while(resultSet.next()){
monthPay+=resultSet.getFloat(1);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_TechnicianSalary);
while(resultSet.next()){
monthPay+=resultSet.getFloat(1);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(count_SalespersonSalary);
while(resultSet.next()){
monthPay+=resultSet.getFloat(1);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
textField_bothSalary.setText(String.valueOf(monthPay)+"元");
}
}
}
});
button_wipe_SalaryCount.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
textField_Manage_Salary.setText("");
textField_SalesManager_Salary.setText("");
textField_Technician_Salary.setText("");
textField_Salesperson_Salary.setText("");
textField_bothSalary.setText("");
}
});
/*
*
*
*
*
* */
jMenuItem1.addActionListener(new ActionListener() {//关于我们
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new About_me().setVisible(true);
}
});
jmenuItem_introduce.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
new Introduce().setVisible(true);
}
});
jMenuItem2.addActionListener(new ActionListener() {//添加基本信息
@Override
public void actionPerformed(ActionEvent e){
// TODO Auto-generated method stub
cardLayout.show(panel_1,"增加基本");
}
});
/*添加基本信息面板中的动作内容*/
btn_confirm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
// TODO Auto-generated method stub
String choose_sex=(String)comboBox_sex.getSelectedItem();
String choose_id=(String)comboBox_admin.getSelectedItem();
if(textField_id.getText().isEmpty()||textField_name.getText().isEmpty()||textField_birthday.getText().isEmpty()||choose_sex.isEmpty()||choose_sex.equals("请选择性别")||choose_id.isEmpty()||choose_id.equals("请选择身份···")){
JOptionPane.showMessageDialog(null,"添加失败,前四项字段不为空,身份必须选择!","提示信息",JOptionPane.ERROR_MESSAGE);
}
else if(textField_birthday.getText().length()!=10||!Check_Date.check_date(textField_birthday.getText())){//日期不符合逻辑
JOptionPane.showMessageDialog(null,"添加失败,日期不符合逻辑(1.当月没有这个日期2.当年没有这个月3.未按格式输入)!","提示信息",JOptionPane.ERROR_MESSAGE);
}
else {
if(choose_sex.equals("请选择性别")){
}
if(choose_sex.equals("男")){
bool=new Boolean(true);
}
if(choose_sex.equals("女")){
bool=new Boolean(false);
}
Date date=null;
try{
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
date=sdf.parse(textField_birthday.getText());
}catch(ParseException e4){
JOptionPane.showMessageDialog(null,"添加失败,日期格式错误(未添加-)!","提示信息",JOptionPane.ERROR_MESSAGE);
}
Connection connection=null;
ResultSet reSet=null;
PreparedStatement pStatement = null;
try {
connection=JDBCUtil.getConnection();
String insertValue="insert into BaseInfo_Table(number,name,sex,birthday,phone,id)Values(?,?,?,?,?,?)";//插入数据的动态设置的SQL语句
pStatement=connection.prepareStatement(insertValue);
pStatement.setString(1,textField_id.getText());
pStatement.setString(2,textField_name.getText());
pStatement.setBoolean(3,bool);
pStatement.setDate(4,new java.sql.Date(date.getTime()));
pStatement.setString(5,textField_phone.getText());
pStatement.setString(6,choose_id);
pStatement.addBatch();
pStatement.executeUpdate();
JOptionPane.showMessageDialog(null,"添加成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e3) {
JOptionPane.showMessageDialog(null,"添加失败,该编号已存在!","提示信息",JOptionPane.ERROR_MESSAGE);//主键重复抛出异常
}finally{
JDBCUtil.release(reSet,pStatement, connection);
}
}
}
});
btn_cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField_id.setText("");
textField_name.setText("");
textField_birthday.setText("");
textField_phone.setText("");
}
});
/*
*
*
*
*
* */
jMenuItem3.addActionListener(new ActionListener() {//增加工资信息
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
cardLayout.show(panel_1,"增加工资");
}
});
/*增加工资信息面板中的动作内容*/
button_addSalary_confirm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String select="select * from BaseInfo_Table where number='"+textField_addSalary.getText()+"'";
Connection connection=null;
Statement statement=null;
ResultSet rSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
rSet=statement.executeQuery(select);
if(rSet.next()){
number=rSet.getString("number");//从基本信息表中获取职工编号然后写入工资信息表中
if(rSet.getString("id").equals("经理")){
cLayout.show(panel_base,"经理");
}
if(rSet.getString("id").equals("技术人员")){
cLayout.show(panel_base,"技术人员");
}
if(rSet.getString("id").equals("销售经理")){
cLayout.show(panel_base,"销售经理");
}
if(rSet.getString("id").equals("销售人员")){
cLayout.show(panel_base,"销售人员");
}
}
else{
JOptionPane.showMessageDialog(null,"未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(rSet, statement, connection);
}
}
});
button_addSalary_canel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO 自动生成的方法存根
textField_addSalary.setText("");
}
});
/*获取的编号是经理职位(进行增加工资信息时)*/
button_Manager_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String addManager="insert into Manager(number,monthPay)values(?,?)";
Connection connection=null;
PreparedStatement pStatement=null;
ResultSet rSet=null;
try {
connection=JDBCUtil.getConnection();
pStatement=connection.prepareStatement(addManager);
pStatement.setString(1,number);
pStatement.setFloat(2,Float.parseFloat(textField_Manager.getText()));
pStatement.executeUpdate();
JOptionPane.showMessageDialog(null,"添加成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,该编号已存在!","提示信息",JOptionPane.ERROR_MESSAGE);
}catch (NumberFormatException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,输入格式错误!","提示信息",JOptionPane.ERROR_MESSAGE);
}finally {
JDBCUtil.release(rSet, pStatement, connection);
}
}
});
/*获取的编号是技术人员职位(进行增加工资信息时)*/
button_Technician_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
Connection connection=null;
PreparedStatement pStatement=null;
ResultSet rSet=null;
String addTechnician="insert into Technician(number,hourRate,workHours,monthPay)values(?,?,?,?)";
float monthPay=Float.parseFloat(textField_Technician_hourRate.getText())*Float.parseFloat(textField_Technician_workHours.getText());
try {
connection=JDBCUtil.getConnection();
pStatement=connection.prepareStatement(addTechnician);
pStatement.setString(1,number);
pStatement.setFloat(2,Float.parseFloat(textField_Technician_hourRate.getText()));
pStatement.setFloat(3,Float.parseFloat(textField_Technician_workHours.getText()));
pStatement.setFloat(4,monthPay);
pStatement.executeUpdate();
JOptionPane.showMessageDialog(null,"添加成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,该编号已存在!","提示信息",JOptionPane.ERROR_MESSAGE);
}catch (NumberFormatException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,输入格式错误!","提示信息",JOptionPane.ERROR_MESSAGE);
}finally {
JDBCUtil.release(rSet, pStatement, connection);
}
}
});
/*获取的编号是销售经理(进行增加工资信息时)*/
button_SalesManager_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
Connection connection=null;
PreparedStatement pStatement=null;
ResultSet rSet=null;
String addSalesManager="insert into SalesManager(number,basePay,pushMoney,sales,monthPay)values(?,?,?,?,?)";
float monthPay=Float.parseFloat(textField_SalesManager_BasePay.getText())+Float.parseFloat(textField_SalesManager_pushMoney.getText())*Float.parseFloat(textField_SalesManager_sales.getText());
try {
connection=JDBCUtil.getConnection();
pStatement=connection.prepareStatement(addSalesManager);
pStatement.setString(1,number);
pStatement.setFloat(2,Float.parseFloat(textField_SalesManager_BasePay.getText()));
pStatement.setFloat(3,Float.parseFloat(textField_SalesManager_pushMoney.getText()));
pStatement.setFloat(4,Float.parseFloat(textField_SalesManager_sales.getText()));
pStatement.setFloat(5, monthPay);
pStatement.executeUpdate();
JOptionPane.showMessageDialog(null,"添加成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e2) {
// TODO: handle exception
//e2.printStackTrace();
JOptionPane.showMessageDialog(null,"添加失败,该编号已存在或提成不在0~1之间!","提示信息",JOptionPane.ERROR_MESSAGE);
}catch (NumberFormatException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,输入格式错误!","提示信息",JOptionPane.ERROR_MESSAGE);
}finally {
JDBCUtil.release(rSet, pStatement, connection);
}
}
});
/*获取的职工编号是销售人员(进行增加工资信息时)*/
button_Salesperson_add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
Connection connection=null;
PreparedStatement pStatement=null;
ResultSet rSet=null;
String addSalesperson="insert into Salesperson(number,pushMoney,sales,monthPay)values(?,?,?,?)";
float monthPay=Float.parseFloat(textField_Salesperson_pushMoney.getText())*Float.parseFloat(textField_Salesperson_sales.getText());
try {
connection=JDBCUtil.getConnection();
pStatement=connection.prepareStatement(addSalesperson);
pStatement.setString(1,number);
pStatement.setFloat(2, Float.parseFloat(textField_Salesperson_pushMoney.getText()));
pStatement.setFloat(3,Float.parseFloat(textField_Salesperson_sales.getText()));
pStatement.setFloat(4,monthPay);
pStatement.executeUpdate();
JOptionPane.showMessageDialog(null,"添加成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,该编号已存在或提成不在0~1之间!","提示信息",JOptionPane.ERROR_MESSAGE);
}catch (NumberFormatException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null,"添加失败,输入格式错误!","提示信息",JOptionPane.ERROR_MESSAGE);
}finally {
JDBCUtil.release(rSet, pStatement, connection);
}
}
});
/*
*
*
*
*
*
*
* */
jMenuItem4.addActionListener(new ActionListener() {//删除基本和工资信息
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
cardLayout.show(panel_1, "删除基本");
}
});
/*删除基本信息和工资信息面板中的动作内容*/
button_delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String sql="select * from BaseInfo_Table where number='"+textField_deleteBase.getText()+"'";
String deleteBase="delete from BaseInfo_Table where number='"+textField_deleteBase.getText()+"'";
Connection connection=null;
Statement statement=null;
ResultSet rSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
rSet=statement.executeQuery(sql);
if(rSet.next()){
delete_old_data[0][0]=rSet.getString(1);
delete_old_data[0][1]=rSet.getString(2);
if(rSet.getBoolean(3)){
delete_old_data[0][2]="男";
}
else{
delete_old_data[0][2]="女";
}
delete_old_data[0][3]=rSet.getDate(4);
delete_old_data[0][4]=rSet.getString(5);
delete_old_data[0][5]=rSet.getString(6);
table_delete_repair = new JTable(delete_old_data,columnNames_delete);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_delete_repair.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_delete_repair.setEnabled(false);//禁止写入
table_delete_repair.getTableHeader().setReorderingAllowed(false);
table_delete_repair.setRowHeight(25);//以像素为单位的行高
scrollPane_delete_old.setViewportView(table_delete_repair);
if (rSet.getString("id").equals("经理")) {
String deleteManager="delete from Manager where number='"+textField_deleteBase.getText()+"'";
Connection connection1=null;
Statement statement1=null;
ResultSet rSet1=null;
try {
connection1=JDBCUtil.getConnection();
statement1=connection1.createStatement();
statement1.executeUpdate(deleteManager);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(rSet1, statement1, connection1);
}
}
if(rSet.getString("id").equals("技术人员")){
String deleteTechnician="delete from Technician where number='"+textField_deleteBase.getText()+"'";
Connection connection2=null;
Statement statement2=null;
ResultSet rSet2=null;
try {
connection2=JDBCUtil.getConnection();
statement2=connection2.createStatement();
statement2.executeUpdate(deleteTechnician);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(rSet2, statement2, connection2);
}
}
if(rSet.getString("id").equals("销售经理")){
String deleteSalesManager="delete from SalesManager where number='"+textField_deleteBase.getText()+"'";
Connection connection3=null;
Statement statement3=null;
ResultSet rSet3=null;
try {
connection3=JDBCUtil.getConnection();
statement3=connection3.createStatement();
statement3.executeUpdate(deleteSalesManager);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(rSet3, statement3, connection3);
}
}
if(rSet.getString("id").equals("销售人员")){
String deleteSalesperson="delete from Salesperson where number='"+textField_deleteBase.getText()+"'";
statement.executeUpdate(deleteSalesperson);
}
JOptionPane.showMessageDialog(null,"删除成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
statement.executeUpdate(deleteBase);
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(rSet, statement, connection);
}
}
});
button_delCanel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
textField_deleteBase.setText("");
}
});
/*
*
*
*
*
*
*
* */
jMenuItem6.addActionListener(new ActionListener() {//修改基本信息
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
cardLayout.show(panel_1, "修改基本");
}
});
/*修改基本信息面板中的动作内容*/
button_repairBase_confirm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String sql="select * from BaseInfo_Table where number='"+textField_repairBase.getText()+"'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(sql);
if(resultSet.next()){
repairBase_old[0][0]=resultSet.getString(1);
repairBase_old[0][1]=resultSet.getString(2);
if(resultSet.getBoolean(3)){
repairBase_old[0][2]="男";
}
else {
repairBase_old[0][2]="女";
}
repairBase_old[0][3]=resultSet.getDate(4);
repairBase_old[0][4]=resultSet.getString(5);
repairBase_old[0][5]=resultSet.getString(6);
table_repairBase_old = new JTable(repairBase_old,columnNames_delete);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_repairBase_old.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_repairBase_old.setEnabled(false);//禁止写入
table_repairBase_old.getTableHeader().setReorderingAllowed(false);//禁止表头拖动
table_repairBase_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairBase_old.setViewportView(table_repairBase_old);
/*修改基本信息窗体*/
RepairBaseInfo repairBaseInfo=new RepairBaseInfo(textField_repairBase.getText());
repairBaseInfo.setResizable(false);//窗体尺寸固定
repairBaseInfo.setVisible(true);
}
else {
JOptionPane.showMessageDialog(null,"未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
});
button_repairBase_cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
textField_repairBase.setText("");
}
});
/*
*
*
*
*
*
* */
jMenuItem7.addActionListener(new ActionListener() {//修改工资信息
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
cardLayout.show(panel_1, "修改工资");
}
});
/*修改工资信息面板的动作内容*/
button_repair_confirm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String sql="select * from BaseInfo_Table where number='"+textField_repairSalary.getText()+"'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(sql);
if(resultSet.next()){
if(resultSet.getString("id").equals("经理")){
String selectManager="select * from Manager where number='"+textField_repairSalary.getText()+"'";
Connection connection1=null;
Statement statement1=null;
ResultSet resultSet1=null;
try {
connection1=JDBCUtil.getConnection();
statement1=connection1.createStatement();
resultSet1=statement1.executeQuery(selectManager);
if(resultSet1.next()){
repairSalary_old[0][0]=resultSet1.getString("number");
repairSalary_old[0][1]=null;
repairSalary_old[0][2]=null;
repairSalary_old[0][3]=null;
repairSalary_old[0][4]=null;
repairSalary_old[0][5]=null;
repairSalary_old[0][6]=resultSet1.getFloat("monthPay");
table_repairSalary_old =new JTable(repairSalary_old,columnNames_repair_Salary);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_repairSalary_old.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_repairSalary_old.setEnabled(false);
table_repairSalary_old.getTableHeader().setReorderingAllowed(false);
table_repairSalary_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairSalary_old.setViewportView(table_repairSalary_old);
/*修改经理工资信息的窗体*/
RepairSalary_Manager repairSalary_Manager=new RepairSalary_Manager(textField_repairSalary.getText());
repairSalary_Manager.setResizable(false);//窗体尺寸固定
repairSalary_Manager.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"工资信息表中未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (Exception e2) {
// TODO: handle exception
}finally {
JDBCUtil.release(resultSet1, statement1, connection1);
}
}
if(resultSet.getString("id").equals("技术人员")){
String selectTechnician="select * from Technician where number='"+textField_repairSalary.getText()+"'";
Connection connection1=null;
Statement statement1=null;
ResultSet resultSet1=null;
try {
connection1=JDBCUtil.getConnection();
statement1=connection1.createStatement();
resultSet1=statement1.executeQuery(selectTechnician);
if(resultSet1.next()){
repairSalary_old[0][0]=resultSet1.getString("number");
repairSalary_old[0][1]=null;
repairSalary_old[0][2]=null;
repairSalary_old[0][3]=null;
repairSalary_old[0][4]=resultSet1.getFloat("hourRate");
repairSalary_old[0][5]=resultSet1.getFloat("workHours");
repairSalary_old[0][6]=resultSet1.getFloat("monthPay");
table_repairSalary_old =new JTable(repairSalary_old,columnNames_repair_Salary);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_repairSalary_old.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_repairSalary_old.setEnabled(false);
table_repairSalary_old.getTableHeader().setReorderingAllowed(false);
table_repairSalary_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairSalary_old.setViewportView(table_repairSalary_old);
/*修改技术人员工资信息的窗体*/
RepairSalary_Technician repairSalary_Technician=new RepairSalary_Technician(textField_repairSalary.getText());
repairSalary_Technician.setResizable(false);//窗体尺寸固定
repairSalary_Technician.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"工资信息表中未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (Exception e2) {
// TODO: handle exception
}finally {
JDBCUtil.release(resultSet1, statement1, connection1);
}
}
if(resultSet.getString("id").equals("销售人员")){
String selectSalesperson="select * from Salesperson where number='"+textField_repairSalary.getText()+"'";
Connection connection1=null;
Statement statement1=null;
ResultSet resultSet1=null;
try {
connection1=JDBCUtil.getConnection();
statement1=connection1.createStatement();
resultSet1=statement1.executeQuery(selectSalesperson);
if(resultSet1.next()){
repairSalary_old[0][0]=resultSet1.getString("number");
repairSalary_old[0][1]=null;
repairSalary_old[0][2]=resultSet1.getFloat("sales");
repairSalary_old[0][3]=resultSet1.getFloat("pushMoney");
repairSalary_old[0][4]=null;
repairSalary_old[0][5]=null;
repairSalary_old[0][6]=resultSet1.getFloat("monthPay");
table_repairSalary_old =new JTable(repairSalary_old,columnNames_repair_Salary);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_repairSalary_old.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_repairSalary_old.setEnabled(false);
table_repairSalary_old.getTableHeader().setReorderingAllowed(false);
table_repairSalary_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairSalary_old.setViewportView(table_repairSalary_old);
/*修改销售人员工资信息的窗体*/
RepairSalary_Salesperson repairSalary_Salesperson=new RepairSalary_Salesperson(textField_repairSalary.getText());
repairSalary_Salesperson.setResizable(false);//窗体尺寸固定
repairSalary_Salesperson.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"工资信息表中未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (Exception e2) {
// TODO: handle exception
}finally {
JDBCUtil.release(resultSet1, statement1, connection1);
}
}
if(resultSet.getString("id").equals("销售经理")){
String selectManager="select * from SalesManager where number='"+textField_repairSalary.getText()+"'";
Connection connection2=null;
Statement statement2=null;
ResultSet resultSet2=null;
try {
connection2=JDBCUtil.getConnection();
statement2=connection2.createStatement();
resultSet2=statement2.executeQuery(selectManager);
if(resultSet2.next()){
repairSalary_old[0][0]=resultSet2.getString("number");
repairSalary_old[0][1]=resultSet2.getFloat("basePay");
repairSalary_old[0][2]=resultSet2.getFloat("sales");
repairSalary_old[0][3]=resultSet2.getFloat("pushMoney");
repairSalary_old[0][4]=null;
repairSalary_old[0][5]=null;
repairSalary_old[0][6]=resultSet2.getFloat("monthPay");
table_repairSalary_old =new JTable(repairSalary_old,columnNames_repair_Salary);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_repairSalary_old.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_repairSalary_old.setEnabled(false);
table_repairSalary_old.getTableHeader().setReorderingAllowed(false);
table_repairSalary_old.setRowHeight(25);//以像素为单位的行高
scrollPane_repairSalary_old.setViewportView(table_repairSalary_old);
/*修改销售经理工资信息的窗体*/
ReapirSalary_SalesManager repairSalary_SalesManager=new ReapirSalary_SalesManager(textField_repairSalary.getText());
repairSalary_SalesManager.setResizable(false);//窗体尺寸固定
repairSalary_SalesManager.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"工资信息表中未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet2, statement2, connection2);
}
}
}
else{
JOptionPane.showMessageDialog(null,"基本信息表中未找到该编号人员信息!","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
}
});
button_repair_canel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
textField_repairSalary.setText("");
}
});
/*
*
*
*
*
*
*
* */
jMenuItem8.addActionListener(new ActionListener() {//查找基本信息
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
cardLayout.show(panel_1,"查找基本");
}
});
/*查找基本信息面板中的动作内容*/
btn_both.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String query="select * from BaseInfo_Table";
Connection connection=null;
Statement statement=null;
ResultSet rSet=null;
int count=0,i=0;//控制以一行一行的读入表,i为表是否为空的标志位
try {
connection=JDBCUtil.getConnection();
connection.setAutoCommit(true);
statement=connection.createStatement();
rSet=statement.executeQuery(query);
while(rSet.next()){
all_Data[count][0]=rSet.getString(1);
all_Data[count][1]=rSet.getString(2);
if (rSet.getBoolean(3)){
all_Data[count][2]="男";
i++;
}
else{
all_Data[count][2]="女";
i++;
}
all_Data[count][3]=rSet.getDate(4);
all_Data[count][4]=rSet.getString(5);
all_Data[count][5]=rSet.getString(6);
count++;
}
if(i==0)
JOptionPane.showMessageDialog(null,"表为空","提示信息",JOptionPane.WARNING_MESSAGE);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(rSet, statement, connection);
}
select_table=new JTable(all_Data,columnNames);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
select_table.setDefaultRenderer(Object.class, renderer);//表中数据居中
select_table.setEnabled(false);//禁止写入
select_table.getTableHeader().setReorderingAllowed(false);//禁止表头拖动
select_table.setRowHeight(25);//以像素为单位的行高
select_table.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane.setViewportView(select_table);
}
});
btn_strictfp.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Connection connection=null;
Statement statement=null;
ResultSet rSet=null;
String select=(String)comboBox_2.getSelectedItem();//当前所选项目
if(select.equals("请选择身份···")||select.isEmpty()){
}
else{
if(select.equals("按编号查找")){
String query="select * from BaseInfo_Table where number='"+textField_8.getText()+"'";
int count=0,i=0;
try {
connection=JDBCUtil.getConnection();
connection.setAutoCommit(true);
statement=connection.createStatement();
rSet=statement.executeQuery(query);
while(rSet.next()){
sec_Data[count][0]=rSet.getString(1);
sec_Data[count][1]=rSet.getString(2);
if (rSet.getBoolean(3)){
sec_Data[count][2]="男";
i++;
}
else{
sec_Data[count][2]="女";
i++;
}
sec_Data[count][3]=rSet.getDate(4);
sec_Data[count][4]=rSet.getString(5);
sec_Data[count][5]=rSet.getString(6);
count++;
}
if(i==0)
JOptionPane.showMessageDialog(null,"编号不存在,请重新输入","提示信息",JOptionPane.WARNING_MESSAGE);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(rSet, statement, connection);
}
select_table=new JTable(sec_Data,columnNames);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
select_table.setDefaultRenderer(Object.class, renderer);//表中数据居中
select_table.setEnabled(false);//禁止写入
select_table.getTableHeader().setReorderingAllowed(false);//禁止表头拖动
select_table.setRowHeight(25);//以像素为单位的行高
select_table.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane.setViewportView(select_table);
}
if(select.equals("按姓名查找")){
String query="select * from BaseInfo_Table where name='"+textField_8.getText()+"'";
int count=0,i=0;
try {
connection=JDBCUtil.getConnection();
connection.setAutoCommit(true);
statement=connection.createStatement();
rSet=statement.executeQuery(query);
while(rSet.next()){
sec_Data[count][0]=rSet.getString(1);
sec_Data[count][1]=rSet.getString(2);
if (rSet.getBoolean(3)){
sec_Data[count][2]="男";
i++;
}
else{
sec_Data[count][2]="女";
i++;
}
sec_Data[count][3]=rSet.getDate(4);
sec_Data[count][4]=rSet.getString(5);
sec_Data[count][5]=rSet.getString(6);
count++;
}
if(i==0||textField_8.getText().equals(""))
JOptionPane.showMessageDialog(null,"姓名不存在,请重新输入","提示信息",JOptionPane.WARNING_MESSAGE);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(rSet, statement, connection);
}
select_table=new JTable(sec_Data,columnNames);
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
select_table.setDefaultRenderer(Object.class, renderer);//表中数据居中
select_table.setEnabled(false);//禁止写入
select_table.getTableHeader().setReorderingAllowed(false);//禁止表头拖动
select_table.setRowHeight(25);//以像素为单位的行高
select_table.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane.setViewportView(select_table);
}
}
}
});
btn_clear.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
select_table=new JTable(empty,columnNames);
select_table.setEnabled(false);//禁止写入
select_table.getTableHeader().setReorderingAllowed(false);//禁止表头拖动
select_table.setRowHeight(25);//以像素为单位的行高
select_table.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane.setViewportView(select_table);
}
});
/*
*
*
*
*
*
*
*
* */
jMenuItem9.addActionListener(new ActionListener() {//查找工资信息
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
cardLayout.show(panel_1, "查找工资");
}
});
/*查找工资信息面板内的动作内容*/
button_select_both.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String queryManager="select * from Manager";
String queryTechnician="select * from Technician";
String querySalesManager="select * from SalesManager";
String querySalesperson="select * from Salesperson";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
int count=0;
try {//经理
connection=JDBCUtil.getConnection();
//connection.setAutoCommit(true);
statement=connection.createStatement();
resultSet=statement.executeQuery(queryManager);
while(resultSet.next()){
selectSalary[count][0]=resultSet.getString(1);
selectSalary[count][1]=null;
selectSalary[count][2]=null;
selectSalary[count][3]=null;
selectSalary[count][4]=null;
selectSalary[count][5]=null;
selectSalary[count][6]=resultSet.getFloat(2);
count++;
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet, statement, connection);
}
try {//技术人员
connection=JDBCUtil.getConnection();
//connection.setAutoCommit(true);
statement=connection.createStatement();
resultSet=statement.executeQuery(queryTechnician);
while(resultSet.next()){
selectSalary[count][0]=resultSet.getString(1);
selectSalary[count][1]=null;
selectSalary[count][2]=null;
selectSalary[count][3]=null;
selectSalary[count][4]=resultSet.getFloat(2);
selectSalary[count][5]=resultSet.getFloat(3);
selectSalary[count][6]=resultSet.getFloat(4);
count++;
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(resultSet, statement, connection);
}
try {//销售经理
connection=JDBCUtil.getConnection();
//connection.setAutoCommit(true);
statement=connection.createStatement();
resultSet=statement.executeQuery(querySalesManager);
while(resultSet.next()){
selectSalary[count][0]=resultSet.getString(1);
selectSalary[count][1]=resultSet.getFloat(2);
selectSalary[count][2]=resultSet.getFloat(4);
selectSalary[count][3]=resultSet.getFloat(3);
selectSalary[count][4]=null;
selectSalary[count][5]=null;
selectSalary[count][6]=resultSet.getFloat(5);
count++;
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(resultSet, statement, connection);
}
try {//销售人员
connection=JDBCUtil.getConnection();
//connection.setAutoCommit(true);
statement=connection.createStatement();
resultSet=statement.executeQuery(querySalesperson);
while(resultSet.next()){
selectSalary[count][0]=resultSet.getString(1);
selectSalary[count][1]=null;
selectSalary[count][2]=resultSet.getFloat(3);
selectSalary[count][3]=resultSet.getFloat(2);
selectSalary[count][4]=null;
selectSalary[count][5]=null;
selectSalary[count][6]=resultSet.getFloat(4);
count++;
}
if(count==0){
JOptionPane.showMessageDialog(null,"工资表为空","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(resultSet, statement, connection);
}
table_select_Salary = new JTable(selectSalary,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_select_Salary.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
table_select_Salary.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane_1.setViewportView(table_select_Salary);
}
});
button_select_strictfp.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String select_strictfp="select number,id from BaseInfo_Table where number='"+textField_select_identity.getText()+"'";
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
connection=JDBCUtil.getConnection();
statement=connection.createStatement();
resultSet=statement.executeQuery(select_strictfp);
if(resultSet.next()){
if (resultSet.getString("id").equals("经理")) {
String select_Manager="select * from Manager where number='"+textField_select_identity.getText()+"'";
Connection connection1=null;
Statement statement1=null;
ResultSet resultSet1=null;
try {
connection1=JDBCUtil.getConnection();
statement1=connection1.createStatement();
resultSet1=statement1.executeQuery(select_Manager);
if(resultSet1.next()){
select_salary_strictfp[0][0]=resultSet1.getString(1);
select_salary_strictfp[0][1]=null;
select_salary_strictfp[0][2]=null;
select_salary_strictfp[0][3]=null;
select_salary_strictfp[0][4]=null;
select_salary_strictfp[0][5]=null;
select_salary_strictfp[0][6]=resultSet1.getFloat(2);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet1, statement1, connection1);
}
table_select_Salary = new JTable(select_salary_strictfp,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_select_Salary.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
table_select_Salary.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane_1.setViewportView(table_select_Salary);
}
if (resultSet.getString("id").equals("技术人员")) {
String select_Manager="select * from Technician where number='"+textField_select_identity.getText()+"'";
Connection connection2=null;
Statement statement2=null;
ResultSet resultSet2=null;
try {
connection2=JDBCUtil.getConnection();
statement2=connection2.createStatement();
resultSet2=statement2.executeQuery(select_Manager);
if(resultSet2.next()){
select_salary_strictfp[0][0]=resultSet2.getString(1);
select_salary_strictfp[0][1]=null;
select_salary_strictfp[0][2]=null;
select_salary_strictfp[0][3]=null;
select_salary_strictfp[0][4]=resultSet2.getFloat(2);
select_salary_strictfp[0][5]=resultSet2.getFloat(3);
select_salary_strictfp[0][6]=resultSet2.getFloat(4);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet2, statement2, connection2);
}
table_select_Salary = new JTable(select_salary_strictfp,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_select_Salary.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
table_select_Salary.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane_1.setViewportView(table_select_Salary);
}
if (resultSet.getString("id").equals("销售经理")) {
String select_Manager="select * from SalesManager where number='"+textField_select_identity.getText()+"'";
Connection connection3=null;
Statement statement3=null;
ResultSet resultSet3=null;
try {
connection3=JDBCUtil.getConnection();
statement3=connection3.createStatement();
resultSet3=statement3.executeQuery(select_Manager);
if(resultSet3.next()){
select_salary_strictfp[0][0]=resultSet3.getString(1);
select_salary_strictfp[0][1]=resultSet3.getFloat(2);
select_salary_strictfp[0][2]=resultSet3.getFloat(4);
select_salary_strictfp[0][3]=resultSet3.getFloat(3);
select_salary_strictfp[0][4]=null;
select_salary_strictfp[0][5]=null;
select_salary_strictfp[0][6]=resultSet3.getFloat(5);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet3, statement3, connection3);
}
table_select_Salary = new JTable(select_salary_strictfp,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_select_Salary.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
table_select_Salary.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane_1.setViewportView(table_select_Salary);
}
if (resultSet.getString("id").equals("销售人员")) {
String select_Manager="select * from Salesperson where number='"+textField_select_identity.getText()+"'";
Connection connection4=null;
Statement statement4=null;
ResultSet resultSet4=null;
try {
connection4=JDBCUtil.getConnection();
statement4=connection4.createStatement();
resultSet4=statement4.executeQuery(select_Manager);
if(resultSet4.next()){
select_salary_strictfp[0][0]=resultSet4.getString(1);
select_salary_strictfp[0][1]=null;
select_salary_strictfp[0][2]=resultSet4.getFloat(3);
select_salary_strictfp[0][3]=resultSet4.getFloat(2);
select_salary_strictfp[0][4]=null;
select_salary_strictfp[0][5]=null;
select_salary_strictfp[0][6]=resultSet4.getFloat(4);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally {
JDBCUtil.release(resultSet4, statement4, connection4);
}
table_select_Salary = new JTable(select_salary_strictfp,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
DefaultTableCellHeaderRenderer renderer=new DefaultTableCellHeaderRenderer();//表中数据居中
renderer.setHorizontalAlignment((int) JTable.CENTER_ALIGNMENT);//表中数据居中
table_select_Salary.setDefaultRenderer(Object.class, renderer);//表中数据居中
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
table_select_Salary.setFont(new Font("宋体", Font.PLAIN, 12));
scrollPane_1.setViewportView(table_select_Salary);
}
}
else{
JOptionPane.showMessageDialog(null,"未找到该职工工资信息","提示信息",JOptionPane.WARNING_MESSAGE);
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}finally{
JDBCUtil.release(resultSet, statement, connection);
}
}
});
button_wipe.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
table_select_Salary = new JTable(selectEmpty,columnNames_select_Salary);
table_select_Salary.setEnabled(false);//禁止写入
table_select_Salary.getTableHeader().setReorderingAllowed(false);
table_select_Salary.setRowHeight(25);//以像素为单位的行高
scrollPane_1.setViewportView(table_select_Salary);
}
});
}
}
九,系统概要
该项目将为公司提供一个平台,该软件将辅助公司对员工基本信息和工资信息的增加、删除、修改、查询,同时还可以对该公司员工数进行统计和对月公司总支出进行统计。该系统包括:登录注册模块、基本数据维护模块、系统介绍模块。