《数据库课程设计商品销售管理系统.docx》由会员分享,可在线阅读,更多相关《数据库课程设计商品销售管理系统.docx(48页珍藏版)》请在课桌文档上搜索。
1、数据库课程设计商品销售管理系统importjava.awt.*;importjavax.swing.*;importjava.sql.*;importjavax.swing.table.AbstractTabIeModel;publicclassLoginBackPanelextendsJFrameimplementsActionListenerprivatestaticfinallongSeriaIVersionUID=IL;JButtonbutton1,button2;JTextFieldFl;Choicec;Containerct=getContentPane();publicLogin
2、BackPaneKStringstr)super(str);setBak();JPanelpanel=newJPanel();panel.setpaque(false);ct.add(panel);panel.setLayout(newFIOWLayoUt(FIoWLayOUt.CENTER,60,20);c=newChoice();c.add(Boss);c.add(Salesman);JLabelJl=newJLabeI(验证身份:);JLabelJ2=newJLabe1(登录密码巧;Fl=newJTextField(9);button1=newJBUItOn(登录);button2=ne
3、wJBUtlon(退出);button1.addActionListener(this);button2.addActionListener(this);panel.add(JI);panel.add(c);panel.add(J2);panel.add(Fl);panel.add(buttonl);panel.add(button2);add(panel);)publicvoidsetBak()设置背景方法(JPanel)this.getContentPane().setOpaque(false);Imageiconimg=newImagelCOn(e:数据库课程设计六月物语Jpg);JLa
4、belbackground=newJLabel(img);this.getLayeredPane().add(background,newInteger(Integer.MIN-VALUE);background.setBounds(0,0,img.getIconWidth(),img.getIconHeight();publicvoidactionPerformed(ActionEvente)if(e.getSource()=button1)Bossif(c.getSelectedItem().equals(H)&F1.getText().equals(,boss)this.dispose(
5、);BSbs=newBS(管理员界面);bs.setSize(500,250);bs.setLocation(450,250);bs.setVisible(true);)Salesmanif(c.getSelectedItem().equals(H)&F1.getText().equals(salesman)(this.dispose();SLSI=newSLf销售员界面”);sl.setSize(500,250);sl.setLocation(450,250);sl.setVisible(true);)1if(e.getSource()=button2)System.exit(O);publ
6、icstaticvoidmain(Stringargs)1.oginBackPanellgp=newLOginBaCkPane1(管理系统登录);lgp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);lgp.setSize(300,200);lgp.setLocation(550,250);lgp.setVisible(true);classBSextendsJFrameimplementsActionListenerJButtonB1,B2,B3,B4,B5,B6,B7;Containerct=getContentPane();publicBS
7、(Stringstr)super(str);setBak();JPanelJP=newJPanel();JP.setOpaque(false);ct.add(JP);JP.setLayout(newFlOWLayoUt(FlOWLayoUt.CENTER,30,50);Bl=newJBUtton(销售情况);B2=newJBUtlon(“客户退货”);B3=newJBUttonC销售收款”);B4=newJBUtKm(“客户信息”);B5=newJButlon(员工管理”);B6=newJBUuon(进货信息);B7=newJBUuOn(“更换角色”);B1.addActionListener
8、(this);B2.addActionListener(this);B3.addActionListener(this);B4.addActionListener(this);B5.addActionListener(this);B6.addActionListener(this);B7.addActionListener(this);JRadd(Bl);JRadd(B2);JP.add(B3);JP.add(B4);JP.add(B5);JP.add(B6);JP.add(B7);add(JP);publicvoidsetBak()(JPanel)this.getContentPane().
9、setOpaque(false);Imageiconimg=newImageICon(e:数据库课程设计六月物语1.jpg);JLabelbackground=newJLabel(img);this.getLayeredPane().add(background,newInteger(Integer.MIN-VALUE);background.setBounds(0,O,img.getlconWidth(),img.getIconHeight();(publicvoidactionPerformed(ActionEvente)if(e.getSource()=B1)this.dispose()
10、;CXFPXXcxfpxx=newCXFPXX(日常销售一发票情况】);cxfpxx.setSize(700,300);cxfpxx.setLocation(350,250);cxfpxx.setVisible(true);)if(e.getSource()=B2)this.dispose();XSTHXXXSthXX=newXSTHXX(日常销售一【销售退货】);xsthxx.setSize(700,300);xsthxx.setLocation(350,250);xsthxx.setVisible(te);)if(e.getSource()=B3)this.dispose();XSXXCX
11、XSXXCX=newXSXXCX(日常销售一【销售收款】);xsxxcx.setSize(700,300);xsxxcx.setLocation(350,250);xsxxcx.setVisible(true);)if(e.getSource()=B4)this.dispose();HYXXCXhyXXCX=newHYXXCX(基本信息管理一【会员信息】);hyxxcx.setSize(700,300);hyxxcx.setLocation(350,250);hyxxcx.setVisible(true);)if(e.getSource()=B5)this.dispose();YGGLyggl
12、=newYGGLf员工管理一【员工信息】);yggl.setSize(500,200);yggl.setLocation(450,250);yggl.setVisible(true);if(e.getSource()=B6)this.dispose();JHXXjhXX=newJHXX(商品更新一【进货信息】);jhxx.setSize(300,l50);jhxx.setLocation(500,250);jhxx.setVisible(true);)if(e.getSource()=B7)this.dispose();1.oginBackPanelxt=newLOginBaCkPane1(管
13、理系统登录);xt.setSize(3OO,2OO);xt.setLocation(550,250);xt.setVisible(true);classBG2extendsAbstractTableModeIStringrq,ph,mc,bh,dj,sl,je;finalStringCOlumnNamesR”开票日期”,“销售票号”,嘀品名称,”商品编号”J商品单价/元/销售数量/个”,”销售金额/元”;Objectdata=new0bject1007;publicBG2()intm=0;StringIIrI=jdbc:microsoft:SqISerVer:IOCalhoSt:1433;Da
14、IabaSeName=课程设计”;Connectioncon;Stringsql;Statementstmt;try(Class.forName(,com.microsoft.jdbc.sqlserver.SQLServerDriver);catch(java.lang.ClassNotFoundExceptione)trycon=DriverManager.getConnection(url,sa,l23456,);stmt=con.createStatement();sql=,SELECT*FROM销售发票;ResultSetrs=stmt.executeQuery(sql);while(
15、rs.next()rq=rs.getString(l);ph=rs.getString(2);mc=rs.getString(3);bh=rs.getString(4);dj=rs.getString(5);sl=rs.getString(6);je=rs.getString(7);datam0=rq;dataml=ph;datam2=mc;datam3=bh;datam4=dj;datam5=sl;datam+6=je;)stmt.close();con.close();)catch(SQLExceptione)System.out.println(0);)publicintgetColum
16、nCount()returnColumnNamesJength;)publicintgetRowCount()returndata.length;)publicStringgetColumnName(intcol)returncolumnNamescol;)publicObjectgetValueAt(introw,intcol)returndatarowcol;)publicvoidsetValueAt(0bjectvalue,introw,intcol)intnumRows=getRowCount();intnumCols=getColumnCount();fbr(inti=0;inumR
17、ows;i+)for(intj=0;jnumCols;j+)System.out.print(+datai11);)classCXFPXXextendsJFrameimplementsActionListenerBG2bg2;JTablet;JButtonb;JPaneIp;JScrollPanes;publicCXFPXX(Stringstr)super(str);setLayout(newBorderLayoutO);b=newJButton(确定”);b.addActionListener(this);p=newJPanel();p.add(b);bg2=newBG2();t=newJT
18、able(bg2);s=newJScrollPane(t);add(s,Center);add(p,South);)publicvoidactionPerfrmed(ActionEvente)if(e.getSource()=b)this.dispose();BScxfpxx=newBS(管理员界面”);cxfpxx.setSize(500,250);cxfpxx.setLocation(450,250);cxfpxx.setVisible(true);classBG3extendsAbstractTableModelStringrq,mc,yy,sl,je;finalStringCoIUmn
19、NameS=“退货日期“,“商品名称”,“退货原因,退货数量/件丫退货金额阮”;Objectdata=new0bject1005;publicBG3()intm=0;StringUIi=jdbc:microsofl:SqISerVe亡IOCaIhOSt:1433;DalabaSeName=课程设计”;Connectioncon;Stringsql;Statementstmt;try(Class.frName(com.microsoft.jdbc.SqlservenSQLServerDriver);catch(java.lang.ClassNotFoundExceptione)try(COn=D
20、riVerManager.getConnection(uH,sa,123456);Stmt=Con.CreateStatementO;sql=,SELECT*FROM退货记录,;ResultSetrs=stmt.executeQuery(sql);while(rs.next()(rq=rs.getString(l);mc=rs.getString(2);yy=rs.getString(3);sl=rs.getString(4);je=rs.getString(5);datam0=rq;dataml=mc;datam2=yy;datam3=sl;datam+4=je;)stmt.close();
21、con.close();)catch(SQLExceptione)System.out.println(0);publicintgetColumnCount()returnColumnNamesJength;)publicintgetRowCount()returndata.length;)publicStringgetColumnName(intcol)returncolumnNamescol;)publicObjectgetValueAt(introw,intcol)returndatarowcol;)publicvoidsetValueAt(Objectvalue,introwjntco
22、l)intnumRows=getRowCount();intnumCols=getColumnCount();for(inti=0;inumRows;i+)fbr(intj=0;jnumCols;j+)System.out.print(+dataij);)classXSTHXXextendsJFrameimplementsActionListenerBG3bg3;JTabIet;JButtonb;JPanelp;JScrollPanes;publicXSTHXX(Stringstr)super(str);setLayout(newBorderLayoutO);b=newJBUttOn(确定);
23、b.addActionListener(this);p=newJPanel();p.add(b);bg3=newBG3();t=newJTable(bg3);s=newJSCrOnPane;add(s,Center);add(p,South);)publicvoidactionPerformed(ActionEvente)if(e.getSource()=b)this.dispose();BScxfpxx=newBS(管理员界面”);cxfpxx.setSize(500,250);cxfpxx.setLocation(450,250);cxfpxx.setVisible(true);class
24、BG4extendsAbstractTableModelStringrq,mc,dj,sl,je;finalStringcolumnNames=”开票日期”,“商品名称商品单价/元”,”销售数量/个”J销售金额/元”;Objectdata=new0bject1005;publicBG4()(intm=0;StringUIi=jdbc:microsofl:SqISerVe亡IOCaIhOSt:1433;DalabaSeName=课程设计”;Connectioncon;Stringsql;Statementstmt;try(Class.frName(com.microsoft.jdbc.Sqlse
25、rvenSQLServerDriver);catch(java.lang.ClassNotFoundExceptione)try(COn=DriVerManager.getConnection(uH,sa,123456);Stmt=Con.CreateStatementO;sql=SELECT开票日期,商品名称,商品单价/元,销售数量/个,销售金额/元FROM销售发票,;ResultSetrs=stmt.executeQuery(sql);while(rs.next()(rq=rs.getString(l);mc=rs.getString(2);dj=rs.getString(3);sl=rs
26、.getString(4);je=rs.getString(5);datamO=rq;datam1=mc;datam2=dj;datam3=sl;datam+4=je;)stmt.close();con.close();catch(SQLExceptione)System.out.println(0);)publicintgetColumnCount()returnColumnNamesJength;)publicintgetRowCount()returndata.length;)publicStringgetColumnName(intcol)returncolumnNamescol;)p
27、ublicObjectgetValueAt(introw,intcol)returndatarowcol;)publicvoidsetValueAt(Objectvalue,introw,intcol)intnumRows=getRowCount();intnumCols=getColumnCount();fbr(inti=0;inumRows;i+)for(intj=0;jnumCols;j+)System.out.print(+datai11);)classXSXXCXextendsJFrameimplementsActionListenerjBG4bg4;JTablet;JButtonb
28、;JPaneIp;JScrollPanes;publicXSXXCX(Stringstr)super(str);setLayout(newBorderLayoutO);b=newJButton(确定”);b.addActionListener(this);p=newJPanel();p.add(b);bg4=newBG4();t=newJTable(bg4);s=newJScrollPane(t);add(s,Center);add(p,South);)publicvoidactionPerfrmed(ActionEvente)if(e.getSource()=b)this.dispose()
29、;BScxfpxx=newBS(管理员界面”);cxfpxx.setSize(500,250);cxfpxx.setLocation(450,250);cxfpxx.setVisible(true);classBG5extendsAbstractTableModelStringch,lx,dz,rq;finalSIringCOkImnNameS=客户称呼J联系方式,”客户地址”,“入会日期”;Objectdata=newObject1004;publicBG5()intm=0;StringUIi=jdbc:microsofl:SqlSerVer:IoCaIhOSt:1433;DalabaSeN
30、ame=课程设计”;Connectioncon;Stringsql;Statementstmt;try(Class.frName(,com.microsoft.jdbc.SqlservenSQLServerDriver);catch(java.lang.ClassNotFoundExceptione)try(con=DriverManager.getConnection(url,sa,123456);Stmt=Con.CreateStatementO;sql=,SELECT*FROM客户信息”;ResultSetrs=stmt.executeQuery(sql);while(rs.next()
31、ch=rs.getString(l);lx=rs.getString(2);dz=rs.getString(3);rq=rs.getString(4);datam0=ch;dataml=lx;datam2=dz;datam+3=rq;)stmt.close();con.close();)catch(SQLExceptione)System.out.println(0);publicintgetColumnCount()returnColumnNamesJength;publicintgetRowCount()returndata.length;)publicStringgetColumnNam
32、e(intcol)returncolumnNamescol;)publicObjectgetValueAt(introw,intcol)returndatarowcol;)publicvoidsetValueAt(Objectvalue,introwjntcol)intnumRows=getRowCount();intnumCols=getColumnCount();fbr(inti=0;inumRows;i+)fbr(intj=0;jnumCols;j+)System.out.print(+datai(j);)classHYXXCXextendsJFrameimplementsActionL
33、istenerfBG5bg5;JTablet;JButtonb;JPaneIp;JScrollPanes;publicHYXXCX(Stringstr)super(str);setLayout(newBorderLayoutO);b=newJButton(确定”);b.addActionListener(this);P=newJPanel();p.add(b);bg5=newBG5();t=newJTable(bg5);s=newJScrollPane;add(s,Center);add(p,South);)publicvoidactionPerformed(ActionEvente)if(e
34、.getSource()=b)this.dispose();BScxfpxx=newBS(管理员界面);cxfpxx.setSize(500,250);cxfpxx.setLocation(450,250);cxfpxx.setVisible(true);classYGGLextendsJFrameimplementsActionListenerJJButtonB1,B2,B3,B4,B5;Containerct=getContentPane();publicYGGL(Stringstr)super(str);setBak();JPanelpanel=newJPanel();panel.set
35、paque(false);panel.setLayout(newFlOWLayoUt(FIoWLayOUt.CENTER,60,40);Bl=newJButlon(添加员工);B2=newJBUuOn(删除员工”);B3=newJButlon(员工名单”);B4=newJBUtlOn(更新信息);B5=newJButtonCig0);B1.addActionListener(this);B2.addActionListener(this);B3.addActionListener(this);B4.addActionListener(this);B5.addActionListener(thi
36、s);panel.add(Bl);panel.add(B2);panel.add(B3);panel.add(B4);panel.add(B5);add(panel);)publicvoidsetBak()(JPanel)this.getContentPane().setOpaque(false);Imageiconimg=newImageICon(e:数据库课程设计六月物语I.jpg);JLabelbackground=newJLabel(img);this.getLayeredPane().add(background,newInteger(Integer.MIN-VALUE);backg
37、round.setBounds(0,0,img.getIconWidth(),img.get!conHeight();publicvoidactionPerformed(ActionEvente)if(e.getSource()=B1)this.dispose();TJYGIjyg=newTJYG(员工管理一【添加员工】”);tjyg.setSize(400,350);tjyg.setLocation(450,200);tjyg.setVisible(true);)if(e.getSource()=B2)this.dispose();SCYGSCyg=newSCYG(员工管理一【删除员工】);
38、scyg.setSize(300J50);scyg.setLocation(550,300);scyg.setVisible(true);)if(e.getSource()=B3)this.dispose();YGMDXXygmdXX=newYGMDXX(员工管理一【员工名单】);ygmdxx.setSize(700,300);ygmdxx.setLocation(350,250);ygmdxx.setVisible(true);)if(e.getSource()=B4)this.dispose();GXXXgxxx=newGXXX(员工管理一更新信息】”);gxxx.setSize(300,
39、200);gxxx.setLocation(500,250);gxxx.setVisible(true);)if(e.getSource()=B5)this.dispose();BSbs=newBS(管理员界面”);bs.setSize(500,250);bs.setLocation(450,250);bs.setVisible(te);classTJYGextendsJFrameimplementsActionListenerfJLabelL1,L2,L3,L4,L5;JTextFieldT1,T2,T3,T4,T5;JButtonB1,B2;Containerct=getContentPa
40、ne();publicTJYG(Stringstr)super(str);setBak();JPanelpanel=newJPanel();panel.setaque(false);panel.setLayout(newFlOWLayOUt(FIoWLayOUt.CENTER,60,25);1.l=newJLabel(员工名称:“);1.2=newJLabel(员工编号:);1.3=newJLabe1(员工职位门);1.4=newJLabe1(聘请日期:);1.5=newJLabeI(联系方式T1=newJTextField(10);T2=newJTextField(10);T3=newJTe
41、xtField(10);T4=newJTextField(10);T5=newJTextField(10);Bl=newJBulton(l);82=加18皿1011(“返回);B1.addActionListener(this);B2.addActionListener(this);panel.add(Ll);panel.add(Tl);panel.add(L2);panel.add(T2);panel.add(L3);panel.add(T3);panel.add(L4);panel.add(T4);panel.add(L5);panel.add(T5);panel.add(Bl);pane
42、l.add(B2);add(panel);)publicvoidsetBak()(JPanel)this.getContentPane().setOpaque(false);Imageiconimg=newImageICon(e:数据库课程设计六月物语2.jpg,);JLabelbackground=newJLabel(ing);this.getLayeredPane().add(background,newInteger(Integer.MIN-VALUE);background.setBounds(0,0,img.getIconWidth(),img.getIconHeight();)pu
43、blicvoidactionPerfbrmed(ActionEvente)if(e.getSource()=B1)StringUH=jdbc:microsoft:SqISerVer:loCaIhOSt:1433;DatabaSeName=课程设计”;Connectioncon;Stringsql;Statementstmt;try(Class.forName(,com.microsoft.jdbc.sqlserver.SQLServerDriver);catch(java.lang.ClassNotFoundExceptionel)el.printStackTrace();)try(con=D
44、riverManager.getConnection(url,sa,123456);Stmt=ConxreateStatementO;sql=*INSERTINTO人员管理(员工名称,员工编号,员工职位,聘请日期,联系方式)VALUES(,+Tl.getText()+,M,+T2.getText()+,u;,+T3.getText()+;,+T4.getText()+,;+T5.getTet()+);StmLexecuteUpdate(Sql);stmt.close();con.close();)catch(SQLExceptione2)e2.printStackTrace();)JoPtiOnPane.showMessageDialog(this,”添加员工成功!提示,JOption