java書店系統畢業設計 使用者模組(3)_java

來源:互聯網
上載者:User

本文執行個體為大家分享了java書店系統畢業設計第3篇,供大家參考,具體內容如下

import java.util.List;import javax.swing.JFrame;import javax.swing.JOptionPane;import cn.hncu.bookStore.user.business.factory.UserEbiFactory;import cn.hncu.bookStore.user.vo.UserModel;/** * * @author __USER__ */public class listPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private JFrame mainFrame = null; public listPanel(JFrame mainFrame) {//初始化 this.mainFrame = mainFrame; initComponents(); myInitDate(); } @SuppressWarnings("unchecked") public listPanel(JFrame mainFrame, List<UserModel> list) { this.mainFrame = mainFrame; initComponents(); jList.setListData(list.toArray()); } @SuppressWarnings("unchecked") private void myInitDate() { List<UserModel> list = UserEbiFactory.getUserEbi().getAll(); jList.setListData(list.toArray()); } //***這一段是自動產生的,下面將不再寫*** /** 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() { jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jList = new javax.swing.JList(); btnToDelete = new javax.swing.JButton(); btnToUpDate = new javax.swing.JButton(); btnToQuery = new javax.swing.JButton(); btnToAdd = new javax.swing.JButton(); setBackground(new java.awt.Color(0, 153, 51)); setMinimumSize(new java.awt.Dimension(800, 600)); setLayout(null); jLabel1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 36)); jLabel1.setForeground(new java.awt.Color(204, 0, 204)); jLabel1.setText("\u7528\u6237\u7ba1\u7406"); add(jLabel1); jLabel1.setBounds(330, 100, 190, 60); jScrollPane1.setForeground(new java.awt.Color(0, 51, 153)); jScrollPane1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); jList.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24)); jList.setModel(new javax.swing.AbstractListModel() {  String[] strings = { "" };  public int getSize() {  return strings.length;  }  public Object getElementAt(int i) {  return strings[i];  } }); jScrollPane1.setViewportView(jList); add(jScrollPane1); jScrollPane1.setBounds(190, 170, 410, 220); btnToDelete.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); btnToDelete.setText("\u5220\u9664\u7528\u6237"); btnToDelete.addActionListener(new java.awt.event.ActionListener() {  public void actionPerformed(java.awt.event.ActionEvent evt) {  btnToDeleteActionPerformed(evt);  } }); add(btnToDelete); btnToDelete.setBounds(240, 470, 110, 40); btnToUpDate.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); btnToUpDate.setText("\u4fee\u6539\u7528\u6237"); btnToUpDate.addActionListener(new java.awt.event.ActionListener() {  public void actionPerformed(java.awt.event.ActionEvent evt) {  btnToUpDateActionPerformed(evt);  } }); add(btnToUpDate); btnToUpDate.setBounds(430, 470, 110, 40); btnToQuery.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); btnToQuery.setText("\u67e5\u627e\u7528\u6237"); btnToQuery.addActionListener(new java.awt.event.ActionListener() {  public void actionPerformed(java.awt.event.ActionEvent evt) {  btnToQueryActionPerformed(evt);  } }); add(btnToQuery); btnToQuery.setBounds(600, 470, 110, 40); btnToAdd.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); btnToAdd.setText("\u6dfb\u52a0\u7528\u6237"); btnToAdd.addActionListener(new java.awt.event.ActionListener() {  public void actionPerformed(java.awt.event.ActionEvent evt) {  btnToAddActionPerformed(evt);  } }); add(btnToAdd); btnToAdd.setBounds(60, 470, 110, 40); }// </editor-fold> //GEN-END:initComponents private void btnToQueryActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new QueryPanel(mainFrame)); mainFrame.validate(); } private void btnToUpDateActionPerformed(java.awt.event.ActionEvent evt) { if (jList.getSelectedValue() == null) {  JOptionPane.showMessageDialog(this, "請選擇要修改的使用者");  return; } String uuid = jList.getSelectedValue().toString().split(",")[0]; mainFrame.setContentPane(new UpdatePanel(mainFrame, uuid)); mainFrame.validate(); } private void btnToDeleteActionPerformed(java.awt.event.ActionEvent evt) { if (jList.getSelectedValue() == null) {  JOptionPane.showMessageDialog(this, "請選擇要刪除的使用者");  return; } String uuid = jList.getSelectedValue().toString().split(",")[0]; mainFrame.setContentPane(new DeletePanel(mainFrame, uuid)); mainFrame.validate(); } private void btnToAddActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new AddPanel(mainFrame)); mainFrame.validate(); } //***這一段是自動產生的,下面將不再寫*** //GEN-BEGIN:variables // Variables declaration - do not modify private javax.swing.JButton btnToAdd; private javax.swing.JButton btnToDelete; private javax.swing.JButton btnToQuery; private javax.swing.JButton btnToUpDate; private javax.swing.JLabel jLabel1; private javax.swing.JList jList; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables}

import javax.swing.JFrame;import javax.swing.JOptionPane;import cn.hncu.bookStore.user.business.factory.UserEbiFactory;import cn.hncu.bookStore.user.common.UserTypeEnum;import cn.hncu.bookStore.user.vo.UserModel;/** * * @author __USER__ */public class AddPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private JFrame mainFrame = null; /** Creates new form AddPanel */ public AddPanel(JFrame mainFrame) { this.mainFrame = mainFrame; initComponents(); myinitDate(); } @SuppressWarnings("unchecked") private void myinitDate() { combType.removeAllItems(); for (UserTypeEnum utm:UserTypeEnum.values()) {  combType.addItem(utm.getName()); } } //***自動產生代碼略過*** // </editor-fold> //GEN-END:initComponents private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new listPanel(mainFrame)); mainFrame.validate(); } private void btnAddActionPerformed(java.awt.event.ActionEvent evt) { String strName = tfdName.getText().trim(); String strUuid = tfdUuid.getText().trim(); String strPwd = new String(tfdPwd.getPassword()); String strPwd2 =new String(tfdPwd2.getPassword()); if (!strPwd.equals(strPwd2)) {  JOptionPane.showMessageDialog(this, "密碼錯誤!");  return; } String strCombType = combType.getSelectedItem().toString(); UserModel um = new UserModel(); um.setName(strName); um.setUuid(strUuid); um.setPwd(strPwd); um.setType(UserTypeEnum.getTypeByName(strCombType)); boolean boo = UserEbiFactory.getUserEbi().create(um); if (boo) {  btnCancelActionPerformed(null); } else {  JOptionPane.showMessageDialog(this, "使用者已存在!");  return; } } //***自動產生代碼略過*** //GEN-BEGIN}

import javax.swing.JFrame;import javax.swing.JOptionPane;import cn.hncu.bookStore.user.business.ebi.UserEbi;import cn.hncu.bookStore.user.business.factory.UserEbiFactory;import cn.hncu.bookStore.user.common.UserTypeEnum;import cn.hncu.bookStore.user.vo.UserModel;/** * * @author __USER__ */public class DeletePanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private JFrame mainFrame = null; private String uuid; UserEbi ebi = UserEbiFactory.getUserEbi(); /** Creates new form AddPanel */ public DeletePanel(JFrame mainFrame, String uuid) { this.mainFrame = mainFrame; this.uuid = uuid; initComponents(); myinitDate(); } @SuppressWarnings("unchecked") private void myinitDate() { UserModel um = ebi.getSingle(uuid); tfdUuid.setText(uuid); tfdUuid.setEnabled(false); tfdName.setText(um.getName()); tfdName.setEnabled(false); tfdPwd.setText(um.getPwd()); tfdPwd.setEnabled(false); tfdPwd2.setText(um.getPwd()); tfdPwd2.setEnabled(false); combType.removeAllItems(); for (UserTypeEnum utm : UserTypeEnum.values()) {  combType.addItem(utm.getName()); } combType.setSelectedIndex(um.getType()); combType.setEnabled(false); } //***自動產生代碼略過*** // </editor-fold> //GEN-END:initComponents private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new listPanel(mainFrame)); mainFrame.validate(); } private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) { boolean boo = ebi.delete(uuid); if (boo) {  btnCancelActionPerformed(null); } else {  JOptionPane.showMessageDialog(this, "刪除使用者失敗,使用者已不存在!");  return; } } //***自動產生代碼略過*** //GEN-BEGIN}

import javax.swing.JFrame;import javax.swing.JOptionPane;import cn.hncu.bookStore.user.business.ebi.UserEbi;import cn.hncu.bookStore.user.business.factory.UserEbiFactory;import cn.hncu.bookStore.user.common.UserTypeEnum;import cn.hncu.bookStore.user.vo.UserModel;/** * * @author __USER__ */public class UpdatePanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private JFrame mainFrame = null; private String uuid; UserEbi ebi = UserEbiFactory.getUserEbi(); /** Creates new form AddPanel */ public UpdatePanel(JFrame mainFrame, String uuid) { this.mainFrame = mainFrame; this.uuid = uuid; initComponents(); myinitDate(); } @SuppressWarnings("unchecked") private void myinitDate() { UserModel um = ebi.getSingle(uuid); tfdUuid.setText(uuid); tfdUuid.setEnabled(false); tfdName.setText(um.getName()); tfdPwd.setText(um.getPwd()); tfdPwd2.setText(um.getPwd()); combType.removeAllItems(); for (UserTypeEnum utm : UserTypeEnum.values()) {  combType.addItem(utm.getName()); } combType.setSelectedIndex(um.getType()); } //***自動產生代碼略過*** // </editor-fold> //GEN-END:initComponents private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new listPanel(mainFrame)); mainFrame.validate(); } private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) { String strName = tfdName.getText().trim(); String strUuid = tfdUuid.getText().trim(); String strPwd = new String(tfdPwd.getPassword()); String strPwd2 =new String(tfdPwd2.getPassword()); if (!strPwd.equals(strPwd2)) {  JOptionPane.showMessageDialog(this, "密碼錯誤!");  return; } String strCombType = combType.getSelectedItem().toString(); UserModel um = new UserModel(); um.setName(strName); um.setUuid(strUuid); um.setPwd(strPwd); um.setType(UserTypeEnum.getTypeByName(strCombType)); boolean boo = UserEbiFactory.getUserEbi().update(um); if (boo) {  btnCancelActionPerformed(null); } else {  JOptionPane.showMessageDialog(this, "使用者已存在!");  return; } } //***自動產生代碼略過*** //GEN-BEGIN}

import java.util.List;import javax.swing.JFrame;import cn.hncu.bookStore.user.business.factory.UserEbiFactory;import cn.hncu.bookStore.user.common.UserTypeEnum;import cn.hncu.bookStore.user.vo.UserModel;import cn.hncu.bookStore.user.vo.UserQueryModel;/** * * @author __USER__ */public class QueryPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private JFrame mainFrame = null; /** Creates new form AddPanel */ public QueryPanel(JFrame mainFrame) { this.mainFrame = mainFrame; initComponents(); myinitDate(); } @SuppressWarnings("unchecked") private void myinitDate() { combType.removeAllItems(); combType.addItem("請選擇"); for (UserTypeEnum utm : UserTypeEnum.values()) {  combType.addItem(utm.getName()); } } //***自動產生代碼略過*** // </editor-fold> //GEN-END:initComponents private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new listPanel(mainFrame)); mainFrame.validate(); } private void btnQueryActionPerformed(java.awt.event.ActionEvent evt) { String strName = tfdName.getText().trim(); String strUuid = tfdUuid.getText().trim(); String strCombType = combType.getSelectedItem().toString(); UserQueryModel uqm=new UserQueryModel(); uqm.setName(strName); uqm.setUuid(strUuid); int type=0; if(combType.getSelectedIndex()>0){  type=UserTypeEnum.getTypeByName(strCombType); } uqm.setType(type); List<UserModel> list= UserEbiFactory.getUserEbi().getByCondition(uqm);  mainFrame.setContentPane(new listPanel(mainFrame,list));  mainFrame.validate(); } //***自動產生代碼略過*** //GEN-BEGIN}

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援雲棲社區。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.