java书店系统毕业设计 用户模块(3)
程序员文章站
2024-03-13 08:29:39
本文实例为大家分享了java书店系统毕业设计第3篇,供大家参考,具体内容如下
import java.util.list;
import javax.s...
本文实例为大家分享了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 }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。