源码获取:博客首页 "资源" 里下载!
功能简介:
销售管理、客户管理、服务管理、统计报表、基础数据、用户管理
客户开发计划界面类:
/**
* 客户开发计划界面类
*
*/
public class ChancePlanInterFrm extends javax.swing.JInternalFrame {
private static final long serialVersionUID = -1952946589926988853L;
private PageBean bean;
private User user;
private SaleChance saleChance;
/** Creates new form ChancePlanInterFrm */
public ChancePlanInterFrm(User user) {
initComponents();
this.setLocation(150, 120);
this.user = user;
checkUser();
}
private void checkUser() {
// this.id = this.user.getid().toString();
saleChance = new SaleChance();
saleChance.setManagerid(user.getid());
saleChance.setStateid(new BigDecimal(2));
QueryInfo info = new QueryInfo();
info.setPagesize(6);
this.fillTable(info, saleChance);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jtb_chance = new javax.swing.JTable();
jb_end = new javax.swing.JButton();
jb_nextpage = new javax.swing.JButton();
jb_previouspage = new javax.swing.JButton();
jb_start = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jtf_id = new javax.swing.JTextField();
jtf_cusname = new javax.swing.JTextField();
jtf_summary = new javax.swing.JTextField();
jtf_contact = new javax.swing.JTextField();
jtf_chancedesc = new javax.swing.JTextField();
jtf_distribute = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jtf_chance_src = new javax.swing.JTextField();
jtf_successpro = new javax.swing.JTextField();
jtf_phone = new javax.swing.JTextField();
jtf_dtb_date = new javax.swing.JTextField();
jScrollPane2 = new javax.swing.JScrollPane();
jtb_plan = new javax.swing.JTable();
jLabel11 = new javax.swing.JLabel();
jtf_date = new JDateChooser();
jLabel12 = new javax.swing.JLabel();
jtf_plan = new javax.swing.JTextField();
jb_save = new javax.swing.JButton();
jb_del = new javax.swing.JButton();
jb_success = new javax.swing.JButton();
jb_fail = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel();
jtf_result = new javax.swing.JTextField();
jb_edit = new javax.swing.JButton();
jlb_record = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jb_add = new javax.swing.JButton();
jLabel15 = new javax.swing.JLabel();
jtf_planid = new javax.swing.JTextField();
setClosable(true);
setIconifiable(true);
setTitle("\u5ba2\u6237\u5f00\u53d1\u8ba1\u5212\u7ba1\u7406");
jtb_chance.setModel(new javax.swing.table.DefaultTableModel(
new Object[][] {
}, new String[] { "编号", "客户名称", "成功率", "概要" }) {
boolean[] canEdit = new boolean[] { false, false, false, false };
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
jtb_chance.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jtb_chanceMouseClicked(evt);
}
});
jScrollPane1.setViewportView(jtb_chance);
jb_end.setText("\u672b\u9875");
jb_end.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_endActionPerformed(evt);
}
});
jb_nextpage.setText("\u4e0b\u4e00\u9875");
jb_nextpage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_nextpageActionPerformed(evt);
}
});
jb_previouspage.setText("\u4e0a\u4e00\u9875");
jb_previouspage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_previouspageActionPerformed(evt);
}
});
jb_start.setText("\u9996\u9875");
jb_start.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_startActionPerformed(evt);
}
});
jLabel1.setText("\u7f16 \u53f7\uff1a");
jLabel2.setText("\u5ba2\u6237\u540d\u79f0\uff1a");
jLabel3.setText("\u6982 \u8981\uff1a");
jLabel4.setText("\u8054 \u7cfb \u4eba\uff1a");
jLabel5.setText("\u673a\u4f1a\u63cf\u8ff0\uff1a");
jLabel6.setText("\u6307 \u6d3e \u7ed9\uff1a");
jtf_id.setEditable(false);
jtf_cusname.setEditable(false);
jtf_summary.setEditable(false);
jtf_contact.setEditable(false);
jtf_chancedesc.setEditable(false);
jtf_distribute.setEditable(false);
jLabel7.setText("\u673a\u4f1a\u6765\u6e90\uff1a");
jLabel8.setText("\u6210\u529f\u51e0\u7387\uff1a");
jLabel9.setText("\u7535 \u8bdd\uff1a");
jLabel10.setText("\u6307\u6d3e\u65f6\u95f4\uff1a");
jtf_chance_src.setEditable(false);
jtf_successpro.setEditable(false);
jtf_phone.setEditable(false);
jtf_dtb_date.setEditable(false);
jtb_plan.setModel(new javax.swing.table.DefaultTableModel(
new Object[][] {
}, new String[] { "编号", "日期", "计划项", "执行效果" }) {
boolean[] canEdit = new boolean[] { false, false, false, false };
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
jScrollPane2.setViewportView(jtb_plan);
jLabel11.setText("\u65e5\u671f\uff1a");
jLabel12.setText("\u8ba1\u5212\uff1a");
jb_save.setText("\u4fdd\u5b58");
jb_save.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_saveActionPerformed(evt);
}
});
jb_del.setText("\u5220\u9664");
jb_del.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_delActionPerformed(evt);
}
});
jb_success.setText("\u5f00\u53d1\u6210\u529f");
jb_success.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_successActionPerformed(evt);
}
});
jb_fail.setText("\u7ec8\u6b62\u5f00\u53d1");
jb_fail.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_failActionPerformed(evt);
}
});
jLabel13.setText("\u6548\u679c\uff1a");
jb_edit.setText("\u7f16\u8f91");
jb_edit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_editActionPerformed(evt);
}
});
jLabel14.setText("jLabel14");
jb_add.setText("\u65b0\u5efa");
jb_add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_addActionPerformed(evt);
}
});
jLabel15.setText("\u7f16\u53f7\uff1a");
jtf_planid.setEditable(false);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addContainerGap()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel3)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_summary,
javax.swing.GroupLayout.PREFERRED_SIZE,
164,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(219,
219,
219))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel4)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_contact,
javax.swing.GroupLayout.PREFERRED_SIZE,
109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(274,
274,
274))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jLabel5)
.addComponent(
jLabel6))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jtf_distribute,
javax.swing.GroupLayout.PREFERRED_SIZE,
84,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18,
18,
18)
.addComponent(
jLabel10)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_dtb_date,
javax.swing.GroupLayout.DEFAULT_SIZE,
198,
Short.MAX_VALUE))
.addComponent(
jtf_chancedesc,
javax.swing.GroupLayout.DEFAULT_SIZE,
365,
Short.MAX_VALUE)))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jlb_record)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel1)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_id))
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel2)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_cusname,
javax.swing.GroupLayout.PREFERRED_SIZE,
106,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(24,
24,
24)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel9)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_phone,
javax.swing.GroupLayout.DEFAULT_SIZE,
170,
Short.MAX_VALUE))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jLabel8)
.addComponent(
jLabel7))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jtf_chance_src,
javax.swing.GroupLayout.DEFAULT_SIZE,
170,
Short.MAX_VALUE)
.addComponent(
jtf_successpro,
javax.swing.GroupLayout.DEFAULT_SIZE,
170,
Short.MAX_VALUE)))))
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jb_start)
.addGap(12,
12,
12)
.addComponent(
jb_nextpage)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_previouspage)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_end)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(
jLabel14,
javax.swing.GroupLayout.DEFAULT_SIZE,
140,
Short.MAX_VALUE))
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
430,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18,
18)))
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGap(18, 18,
18)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE,
426,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(39,
39,
39))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jb_edit)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_del)
.addGap(10,
10,
10)
.addComponent(
jb_success)
.addGap(6,
6,
6)
.addComponent(
jb_fail))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel12)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_plan,
javax.swing.GroupLayout.DEFAULT_SIZE,
320,
Short.MAX_VALUE))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel13)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_result,
javax.swing.GroupLayout.DEFAULT_SIZE,
320,
Short.MAX_VALUE)))
.addGap(104,
104,
104))
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel11)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_date,
javax.swing.GroupLayout.PREFERRED_SIZE,
148,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18,
18,
18)
.addComponent(
jLabel15)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_planid,
javax.swing.GroupLayout.PREFERRED_SIZE,
35,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())))
.addGroup(
layout.createSequentialGroup()
.addGap(83, 83,
83)
.addComponent(
jb_add)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(
jb_save)
.addContainerGap()))));
layout.setVerticalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addContainerGap()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
139,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jlb_record)
.addComponent(
jb_previouspage)
.addComponent(
jb_end)
.addComponent(
jb_start)
.addComponent(
jb_nextpage)
.addComponent(
jLabel14))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel7)
.addComponent(
jtf_chance_src,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel8)
.addComponent(
jtf_successpro,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jtf_id,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel1))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel2)
.addComponent(
jtf_cusname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE,
210,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jb_edit)
.addComponent(
jb_del)
.addComponent(
jb_success)
.addComponent(
jb_fail))))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGap(6,
6,
6)
.addComponent(
jLabel3))
.addComponent(
jtf_summary,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel4)
.addComponent(
jLabel9)
.addComponent(
jtf_contact,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jtf_phone,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel5)
.addComponent(
jtf_chancedesc,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel6)
.addComponent(
jLabel10)
.addComponent(
jtf_distribute,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jtf_dtb_date,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel11)
.addComponent(
jtf_date,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(
layout.createSequentialGroup()
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel15)
.addComponent(
jtf_planid,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel12)
.addComponent(
jtf_plan,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jLabel13)
.addComponent(
jtf_result,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jb_save)
.addComponent(
jb_add))))
.addContainerGap(50, Short.MAX_VALUE)));
pack();
}// </editor-fold>
//GEN-END:initComponents
private void jb_addActionPerformed(java.awt.event.ActionEvent evt) {
Date date = this.jtf_date.getDate();
String con_content = this.jtf_plan.getText();
String id = this.jtf_id.getText();
if (StringUtil.isEmpty(id)) {
JOptionPane.showMessageDialog(this, "请先选择一项销售机会");
return;
}
BigDecimal chanceid = StringUtil.formatString(id);
Plan plan = new Plan();
plan.setChanceid(chanceid);
// plan.setDate(DateUtil.formatString(date, "yyyy-mm-dd"));
plan.setDate(date);
plan.setCon_content(con_content);
boolean b = SaleEbiFactory.getSaleEbi().addPlan(plan);
if (b) {
JOptionPane.showMessageDialog(this, "添加成功!");
reset();
} else {
JOptionPane.showMessageDialog(this, "添加失败!");
}
}
private void reset(){
this.jtf_plan.setText("");
this.jtf_planid.setText("");
this.jtf_date.setDate(null);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private void jtb_chanceMouseClicked(java.awt.event.MouseEvent evt) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_chance
.getModel();
int selectRows = jtb_chance.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_chance.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String chanceId = tableModel.getValueAt(selectedRowIndex, 0)
.toString();
SaleChance saleChance = SaleEbiFactory.getSaleEbi()
.search(chanceId);
this.jtf_id.setText(saleChance.getChanceid().toString());
this.jtf_cusname.setText(saleChance.getCus_name());
this.jtf_chance_src.setText(saleChance.getChance_src());
this.jtf_contact.setText(saleChance.getContact());
this.jtf_chancedesc.setText(saleChance.getChance_desc());
TIMESTAMP time = saleChance.getDtb_date();
String dtb_date = DateUtil.formatTimestamp(time);
this.jtf_dtb_date.setText(dtb_date);
this.jtf_successpro.setText(saleChance.getSuccess_pro().toString());
this.jtf_summary.setText(saleChance.getSummary());
this.jtf_phone.setText(saleChance.getContact_phone());
String managerid = saleChance.getManagerid().toString();
CusManager cusManager = UserEbiFactory.getUserEbi().searchManager(
managerid);
this.jtf_distribute.setText(cusManager.getManager_name());
List<Plan> list = SaleEbiFactory.getSaleEbi().getPlans(chanceId);
DefaultTableModel dtm = (DefaultTableModel) this.jtb_plan
.getModel();
dtm.setRowCount(0);
for (Plan plan : list) {
Vector v = new Vector();
v.add(plan.getPlanid());
v.add(plan.getPlan_date());
v.add(plan.getCon_content());
v.add(plan.getResult());
dtm.addRow(v);
}
}
}
private void jb_saveActionPerformed(java.awt.event.ActionEvent evt) {
String planid = this.jtf_planid.getText();
String con_content = this.jtf_plan.getText();
String result = this.jtf_result.getText();
Plan plan = new Plan();
plan.setCon_content(con_content);
plan.setResult(result);
boolean b = SaleEbiFactory.getSaleEbi().savePlan(plan, planid);
if (b) {
JOptionPane.showMessageDialog(this, "保存成功!");
reset();
} else {
JOptionPane.showMessageDialog(this, "保存失败!");
}
}
private void jb_failActionPerformed(java.awt.event.ActionEvent evt) {
int flag = JOptionPane
.showConfirmDialog(this, "确认此记录开发失败?\n此操作将不可恢复!", "确认信息",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (flag == 0) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_chance
.getModel();
int selectRows = jtb_chance.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_chance.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String chanceid = tableModel.getValueAt(selectedRowIndex, 0)
.toString();
boolean b = SaleEbiFactory.getSaleEbi().failPlan(chanceid);
if (b) {
JOptionPane.showMessageDialog(this, "已提交!");
} else {
JOptionPane.showMessageDialog(this, "提交失败");
}
}
}
}
private void jb_successActionPerformed(java.awt.event.ActionEvent evt) {
int flag = JOptionPane.showConfirmDialog(this,
"确认此记录已开发成功?\n此操作将不可恢复!", "确认信息", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (flag == 0) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_chance
.getModel();
int selectRows = jtb_chance.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_chance.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String chanceid = tableModel.getValueAt(selectedRowIndex, 0)
.toString();
boolean b = SaleEbiFactory.getSaleEbi().successPlan(chanceid);
if (b) {
JOptionPane.showMessageDialog(this, "已提交!");
} else {
JOptionPane.showMessageDialog(this, "提交失败");
}
}
}
}
private void jb_delActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_plan.getModel();
int selectRows = jtb_plan.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_plan.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String planid = tableModel.getValueAt(selectedRowIndex, 0)
.toString();
if (StringUtil.isEmpty(planid)) {
JOptionPane.showMessageDialog(this, "请选择一条记录");
return;
}
int flag = JOptionPane.showConfirmDialog(this, "确认删除此记录?", "确认信息",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (flag == 0) {
boolean b = SaleEbiFactory.getSaleEbi().delPlan(planid);
if (b) {
JOptionPane.showMessageDialog(this, "删除计划项成功");
} else {
JOptionPane.showMessageDialog(this, "删除失败");
}
}
}
}
private void jb_editActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_plan.getModel();
int selectRows = jtb_plan.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_plan.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String planid = tableModel.getValueAt(selectedRowIndex, 0)
.toString();
String plan_date = tableModel.getValueAt(selectedRowIndex, 1)
.toString();
String con_content = tableModel.getValueAt(selectedRowIndex, 2)
.toString();
this.jtf_planid.setText(planid);
// this.jtf_date.setText(plan_date);
this.jtf_date.setDate(DateUtil.formatString(plan_date, "yyyy-M-dd"));
this.jtf_plan.setText(con_content);
String result = "";
try {
result = tableModel.getValueAt(selectedRowIndex, 3).toString();
} catch (NullPointerException e) {
}
this.jtf_result.setText(result);
}
}
private void jb_endActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(bean.getTotalpage());
info.setPagesize(6);
fillTable(info, saleChance);
}
private void jb_previouspageActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(bean.getPreviouspage());
info.setPagesize(6);
fillTable(info, saleChance);
}
private void jb_nextpageActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(bean.getNextpage());
info.setPagesize(6);
fillTable(info, saleChance);
}
private void jb_startActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(1);
info.setPagesize(6);
fillTable(info, saleChance);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void fillTable(QueryInfo info, SaleChance saleChance) {
// 获取表格模型
DefaultTableModel dtm = (DefaultTableModel) this.jtb_chance.getModel();
// 清空表格
dtm.setRowCount(0);
// 获取业务层接口实现类对象
SaleEbi saleEbi = SaleEbiFactory.getSaleEbi();
// 查询数据
bean = saleEbi.searchAll(info, saleChance);
// 获取封装数据的集合
List list = bean.getList();
// 遍历集合并向表格填充数据
for (Object object : list) {
Vector v = new Vector();
SaleChance saleChance2 = (SaleChance) object;
v.add(saleChance2.getChanceid());
v.add(saleChance2.getCus_name());
v.add(saleChance2.getSuccess_pro());
v.add(saleChance2.getSummary());
dtm.addRow(v);
}
this.jLabel14.setText("共" + bean.getTotalrecord() + "条记录-共"
+ bean.getTotalpage() + "页-当前第" + bean.getCurrentpage() + "页");
}
// GEN-
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JButton jb_add;
private javax.swing.JButton jb_del;
private javax.swing.JButton jb_edit;
private javax.swing.JButton jb_end;
private javax.swing.JButton jb_fail;
private javax.swing.JButton jb_nextpage;
private javax.swing.JButton jb_previouspage;
private javax.swing.JButton jb_save;
private javax.swing.JButton jb_start;
private javax.swing.JButton jb_success;
private javax.swing.JLabel jlb_record;
private javax.swing.JTable jtb_chance;
private javax.swing.JTable jtb_plan;
private javax.swing.JTextField jtf_chance_src;
private javax.swing.JTextField jtf_chancedesc;
private javax.swing.JTextField jtf_contact;
private javax.swing.JTextField jtf_cusname;
private JDateChooser jtf_date;
private javax.swing.JTextField jtf_distribute;
private javax.swing.JTextField jtf_dtb_date;
private javax.swing.JTextField jtf_id;
private javax.swing.JTextField jtf_phone;
private javax.swing.JTextField jtf_plan;
private javax.swing.JTextField jtf_planid;
private javax.swing.JTextField jtf_result;
private javax.swing.JTextField jtf_successpro;
private javax.swing.JTextField jtf_summary;
// End of variables declaration//GEN-END:variables
}
登录控制层:
/**
* 登录控制层
*/
public class LoginFrm extends javax.swing.JFrame {
/**
* 皮肤
*/
static {
try {
// LookAndFeel lf = new SubstanceAutumnLookAndFeel();
// LookAndFeel lf = new SubstanceChallengerDeepLookAndFeel();
// LookAndFeel lf = new Plastic3DLookAndFeel();
// LookAndFeel lf = new PlasticLookAndFeel();
LookAndFeel lf = new PlasticXPLookAndFeel();
UIManager.setLookAndFeel(lf);
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
}
/**
* 版本序列号
*/
private static final long serialVersionUID = -2989784724450522952L;
// 验证码的String类型
private String imageCode;
private User user;
/** Creates new form LoginFrm */
public LoginFrm(User user) {
this.user = user;
initComponents();
this.setLocationRelativeTo(null);
fillImageCode();
if (user != null) {
this.jtf_username.setText(this.user.getusername());
this.jpw_password.setText(this.user.getpassword());
}
}
public void setUser(User user) {
this.user = user;
}
/**
* 填充验证码图片
*/
private void fillImageCode() {
// this.jl_checkImage.setIcon(new ImageIcon("images/check.jpeg"));
// this.repaint();
// jl_checkImage.setIcon(new ImageIcon(ImageIO.read(new
// File("images/check.jpeg"))));
ImageCodeUtil imageCodeUtil = ImageCodeUtil.getImageCodeUtil();
jl_checkImage.setIcon(new ImageIcon(imageCodeUtil.getBufferedImage()));
imageCode =imageCodeUtil.sRand;
}
// GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jtf_username = new javax.swing.JTextField();
jpw_password = new javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
jtf_check = new javax.swing.JTextField();
jl_checkImage = new javax.swing.JLabel();
jb_login = new javax.swing.JButton();
jb_cancle = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("\u7528\u6237\u767b\u5f55");
jLabel1.setFont(new java.awt.Font("宋体", 0, 24));
jLabel1.setText("\u5ba2\u6237\u5173\u7cfb\u7ba1\u7406\u7cfb\u7edf");
jLabel2.setText("\u7528\u6237\u540d\uff1a");
jLabel3.setText("\u5bc6 \u7801\uff1a");
jLabel4.setText("\u9a8c\u8bc1\u7801\uff1a");
jb_login.setText("\u767b\u5f55");
jb_login.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_loginActionPerformed(evt);
}
});
jb_cancle.setText("\u53d6\u6d88");
jb_cancle.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_cancleActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGap(108,
108,
108)
.addComponent(
jLabel1))
.addGroup(
layout.createSequentialGroup()
.addGap(78, 78,
78)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(
jLabel2)
.addComponent(
jLabel3)
.addComponent(
jLabel4))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addGroup(
javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jtf_check,
javax.swing.GroupLayout.PREFERRED_SIZE,
71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(
jl_checkImage))
.addComponent(
jpw_password,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
157,
Short.MAX_VALUE)
.addComponent(
jtf_username,
javax.swing.GroupLayout.Alignment.LEADING)))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jb_login)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(
jb_cancle)))))
.addContainerGap(79, Short.MAX_VALUE)));
layout.setVerticalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
jtf_username,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
jpw_password,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(
jtf_check,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jl_checkImage))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED,
38, Short.MAX_VALUE)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jb_login)
.addComponent(jb_cancle))
.addContainerGap()));
pack();
}// </editor-fold>
// GEN-END:initComponents
private void jb_cancleActionPerformed(java.awt.event.ActionEvent evt) {
int i = JOptionPane.showConfirmDialog(this, "确定退出系统?", "确认信息",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (i == 0) {
this.dispose();
}
}
private void jb_loginActionPerformed(java.awt.event.ActionEvent evt) {
String userName = this.jtf_username.getText();
String password = new String(this.jpw_password.getPassword());
String checkCode = this.jtf_check.getText();
if (StringUtil.isEmpty(userName)) {
JOptionPane.showMessageDialog(this, "用户名不能为空!");
return;
}
if (StringUtil.isEmpty(password)) {
JOptionPane.showMessageDialog(this, "密码不能为空");
return;
}
if (!checkCode.equals(imageCode)) {
JOptionPane.showMessageDialog(this, "验证码错误");
// this.fillImageCode();
// this.jl_checkImage.updateUI();
// this.pack();
return;
}
User user = new User(userName, password);
UserEbi userEbi = UserEbiFactory.getUserEbi();
User currentUser = userEbi.login(user);
if (currentUser == null) {
JOptionPane.showMessageDialog(this, "用户名或密码错误!");
return;
}
// System.out.println("登录成功");
this.dispose();
new MainFrm(currentUser).setVisible(true);
}
/**
* @param args
* the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LoginFrm(null).setVisible(true);
}
});
}
// GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JButton jb_cancle;
private javax.swing.JButton jb_login;
private javax.swing.JLabel jl_checkImage;
private javax.swing.JPasswordField jpw_password;
private javax.swing.JTextField jtf_check;
private javax.swing.JTextField jtf_username;
// End of variables declaration//GEN-END:variables
}
用户管理服务类:
/**
* 用户管理服务类
*/
public class UserSerInterFrm extends javax.swing.JInternalFrame {
/**
*
*/
private static final long serialVersionUID = -8462503234613628488L;
private PageBean bean = null;
/** Creates new form UserSerInterFrm */
public UserSerInterFrm() {
initComponents();
this.setLocation(230, 130);
this.fillRole();
QueryInfo info = new QueryInfo();
info.setPagesize(9);
this.fillTable(info);
}
private void fillRole() {
DefaultComboBoxModel dcm = (DefaultComboBoxModel) this.jcb_role
.getModel();
dcm.removeAllElements();
List<Role> list = RoleEbiFactory.getRoleEbo().getRole();
for (Role role : list) {
dcm.addElement(role);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jtb_user = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jtf_username = new javax.swing.JTextField();
jtf_password = new javax.swing.JTextField();
jcb_role = new javax.swing.JComboBox();
jb_modify = new javax.swing.JButton();
jb_del = new javax.swing.JButton();
jb_end = new javax.swing.JButton();
jb_nextpage = new javax.swing.JButton();
jb_previouspage = new javax.swing.JButton();
jb_start = new javax.swing.JButton();
jb_add = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
setClosable(true);
setIconifiable(true);
setTitle("\u7528\u6237\u7ba1\u7406");
jtb_user.setModel(new javax.swing.table.DefaultTableModel(
new Object[][] {
}, new String[] { "编号", "用户名", "角色" }) {
boolean[] canEdit = new boolean[] { false, false, false };
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
jtb_user.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jtb_userMouseClicked(evt);
}
});
jScrollPane1.setViewportView(jtb_user);
jLabel1.setText("\u7528\u6237\u540d\uff1a");
jLabel2.setText("\u5bc6 \u7801\uff1a");
jLabel3.setText("\u89d2 \u8272\uff1a");
jcb_role.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
"Item 1", "Item 2", "Item 3", "Item 4" }));
jb_modify.setText("\u4fee\u6539");
jb_modify.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_modifyActionPerformed(evt);
}
});
jb_del.setText("\u5220\u9664");
jb_del.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_delActionPerformed(evt);
}
});
jb_end.setText("\u672b\u9875");
jb_end.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_endActionPerformed(evt);
}
});
jb_nextpage.setText("\u4e0b\u4e00\u9875");
jb_nextpage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_nextpageActionPerformed(evt);
}
});
jb_previouspage.setText("\u4e0a\u4e00\u9875");
jb_previouspage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_previouspageActionPerformed(evt);
}
});
jb_start.setText("\u9996\u9875");
jb_start.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_startActionPerformed(evt);
}
});
jb_add.setText("\u65b0\u5efa");
jb_add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_addActionPerformed(evt);
}
});
jLabel4.setText("jLabel4");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(
87,
Short.MAX_VALUE)
.addComponent(
jb_start)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_previouspage)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_nextpage)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_end)
.addGap(39, 39,
39))
.addGroup(
layout.createSequentialGroup()
.addContainerGap()
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
359,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
271,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28,
28)))
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel1)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_username,
javax.swing.GroupLayout.PREFERRED_SIZE,
125,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel2)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jtf_password))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel3)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jcb_role,
javax.swing.GroupLayout.PREFERRED_SIZE,
75,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jb_add)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_modify)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jb_del)))
.addContainerGap(20, Short.MAX_VALUE)));
layout.setVerticalGroup(layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
199,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel4)
.addGap(4, 4, 4)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jb_end)
.addComponent(jb_nextpage)
.addComponent(jb_previouspage)
.addComponent(jb_start)
.addComponent(jb_del)
.addComponent(jb_modify)
.addComponent(jb_add))
.addContainerGap(45, Short.MAX_VALUE))
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(99, Short.MAX_VALUE)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(
jtf_username,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
jtf_password,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(
layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
jcb_role,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(98, 98, 98)));
pack();
}// </editor-fold>
//GEN-END:initComponents
private void jtb_userMouseClicked(java.awt.event.MouseEvent evt) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_user.getModel();
int selectRows = jtb_user.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_user.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String id = tableModel.getValueAt(selectedRowIndex, 0).toString();
User user = UserEbiFactory.getUserEbi().search(id);
this.jtf_username.setText(user.getusername());
this.jtf_password.setText(user.getpassword());
// Role[] role = (Role[]) this.jcb_role.getSelectedObjects();
// for (Role r: role) {
// if (r.getId()==user.getid()) {
// this.jcb_role.setSelectedItem(r);
// }
// }
for (int i = 0; i < this.jcb_role.getItemCount(); i++) {
Role role = (Role) this.jcb_role.getItemAt(i);
if (role.getId() == user.getroleid()) {
this.jcb_role.setSelectedIndex(i);
}
}
}
}
private void jb_endActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(bean.getTotalpage());
info.setPagesize(9);
fillTable(info);
}
private void jb_nextpageActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(bean.getNextpage());
info.setPagesize(9);
fillTable(info);
}
private void jb_previouspageActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(bean.getPreviouspage());
info.setPagesize(9);
fillTable(info);
}
private void jb_startActionPerformed(java.awt.event.ActionEvent evt) {
QueryInfo info = new QueryInfo();
info.setCurrentpage(1);
info.setPagesize(9);
fillTable(info);
}
private void jb_modifyActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_user.getModel();
int selectRows = jtb_user.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_user.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
BigDecimal userId = (BigDecimal) tableModel.getValueAt(
selectedRowIndex, 0);
String username = this.jtf_username.getText();
String password = this.jtf_password.getText();
Role role = (Role) this.jcb_role.getSelectedItem();
BigDecimal roleId = role.getId();
User user = new User(userId, username, password, roleId);
boolean b = UserEbiFactory.getUserEbi().update(user);
if (b) {
JOptionPane.showMessageDialog(this, "修改成功!");
} else {
JOptionPane.showMessageDialog(this, "修改失败!");
}
}
}
private void jb_addActionPerformed(java.awt.event.ActionEvent evt) {
String username = this.jtf_username.getText();
String password = this.jtf_password.getText();
User user = new User(username, password, new BigDecimal(5));
boolean b = UserEbiFactory.getUserEbi().add(user);
if (b) {
JOptionPane.showMessageDialog(this, "添加成功!");
} else {
JOptionPane.showMessageDialog(this, "添加失败!");
}
}
private void jb_delActionPerformed(java.awt.event.ActionEvent evt) {
int i = JOptionPane.showConfirmDialog(this, "确认删除此条记录?", "确认信息",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (i == 0) {
DefaultTableModel tableModel = (DefaultTableModel) jtb_user
.getModel();
int selectRows = jtb_user.getSelectedRows().length;// 取得用户所选行的行数
int selectedRowIndex = jtb_user.getSelectedRow(); // 取得用户所选单行
if (selectRows == 1) {
String userId = tableModel.getValueAt(selectedRowIndex, 0)
.toString();
boolean b = UserEbiFactory.getUserEbi().del(userId);
if (b) {
JOptionPane.showMessageDialog(this, "删除成功!");
} else {
JOptionPane.showMessageDialog(this, "删除失败!");
}
}
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void fillTable(QueryInfo info) {
// 获取表格模型
DefaultTableModel dtm = (DefaultTableModel) this.jtb_user.getModel();
// 清空表格
dtm.setRowCount(0);
// 获取业务层接口实现类对象
UserEbi userEbi = UserEbiFactory.getUserEbi();
// 查询数据
bean = userEbi.search(info);
// 获取封装数据的集合
List list = bean.getList();
// 遍历集合并向表格填充数据
for (Object object : list) {
Vector v = new Vector();
User user = (User) object;
v.add(user.getid());
v.add(user.getusername());
v.add(user.getRolename());
dtm.addRow(v);
}
this.jLabel4.setText("共" + bean.getTotalrecord() + "条记录-共"
+ bean.getTotalpage() + "页-当前第" + bean.getCurrentpage() + "页");
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton jb_add;
private javax.swing.JButton jb_del;
private javax.swing.JButton jb_end;
private javax.swing.JButton jb_modify;
private javax.swing.JButton jb_nextpage;
private javax.swing.JButton jb_previouspage;
private javax.swing.JButton jb_start;
private javax.swing.JComboBox jcb_role;
private javax.swing.JTable jtb_user;
private javax.swing.JTextField jtf_password;
private javax.swing.JTextField jtf_username;
// End of variables declaration//GEN-END:variables
}
源码获取:博客首页 "资源" 里下载!
本文转载自: https://blog.csdn.net/m0_66863468/article/details/123103357
版权归原作者 qq1334611189 所有, 如有侵权,请联系我们删除。
版权归原作者 qq1334611189 所有, 如有侵权,请联系我们删除。