收藏 分销(赏)

数据库课程设计 商品销售管理系统.pdf

上传人:曲**** 文档编号:229391 上传时间:2023-03-20 格式:PDF 页数:50 大小:1.68MB
下载 相关 举报
数据库课程设计 商品销售管理系统.pdf_第1页
第1页 / 共50页
数据库课程设计 商品销售管理系统.pdf_第2页
第2页 / 共50页
数据库课程设计 商品销售管理系统.pdf_第3页
第3页 / 共50页
数据库课程设计 商品销售管理系统.pdf_第4页
第4页 / 共50页
数据库课程设计 商品销售管理系统.pdf_第5页
第5页 / 共50页
点击查看更多>>
资源描述

1、i m port ja v a.aw t.event.*;im p ort java,a w t.*;i m p or t j a vax.sw i n g.*;import j ava.sq 1.*;import j a vax.s w i ng.t able.Abst r a c tTa b 1 e M o del;pub 1 ic c l a s s Lo g inBac k P an e 1 exte n ds JF r ame imp 1 ements Ac t ionLis t enerp r iv a te sta t ic fin a 1 long se r i a IVe r

2、 sionUID=1 L;JBu t t on b u ttonl,b utt o n 2;J T e x t F ield Fl;C h oic e c;Co n t a in e r c t=ge t Cont e ntPa n e();public LoginB a c kPa n el(Stri n g s tr)supe r(str);setB a k();J Panel pa n el=n ew JPanel();pane 1.s etOpaq u e(false);c t.add(p an e 1);p an e LsetLayout(n ew Flow Layout(F 1 o

3、w La you t.CENTE R,60,2 0);c=ne w Choi c e();c.add(Bo s s);c.a d d(Salesman);JLabel J1=n ew JLab e 1(验证身份:);J Labe 1 J2=new JLab e 1(登录密码:);Fl=n e w JTextField(9);bu t t o nl=new JBut t on(登录);but t o n 2=new JB u tt o n(退出)b uttonl.addAc tion Listen e r(t his);b u tton2.a d d A c t ionLi s t ene r(

4、thi s);p a nel.a d d(J 1);panel.add(c);panel.ad d(J2);p an e l.ad d(Fl);p anel.add(but tonl);p a nel.ad d(butto n 2);a dd(pan e 1);)publi c voi d set B a k()/设置背景方法(JPanel)this,getC o nt e ntPan e().setOpa q u e(f alse);I m agel c o n i m g=n e w I mag e I c on(e:/数据库课程设计/六月物语.JPg);J Label b ac k g

5、r ound=new JLab e l(img);this.g e t La y e r edPa n e().add(bac kgr o und,new In t ege r(I n teg e r.MI N VALUE);bac k grou n d.s etB o un d s(0,0,img.ge t Ic onWi d th(),i mg.getl c o nHeig h t();p u b 1 ic void a c t io n Per f o r m ed(A c ti o nEv e nt e)i f(e.get S ourc e()=buttonl)o if(c.getS

6、elec te d Item().e quals(Boss)&F1.getText().eq u als(b os s)s o t h is.d i spose();o o o BSbs=new BS(管理员界面);o o bs.setSize(50 0,250);*bs.setLoc a tion(4 5 0,25 0);bs.setVisib 1 e(t r ue);)s o if(c.get S e 1 e c t e dltem().equ a 1 s(S ales m an)&F1.g e t Text().e q ua 1 s(sal e sma n)s hi s.dis p o

7、s e();o 8 SL s 1=new S L(销售员界面);8。sl.setSize(5 00,2 5 0);。8 sl.s e tLoc a t ion(4 50,25 0);o sl.s e t Vi s i b 1 e(true);O 00 0)o if(e.ge t Sou r c e()=bu t ton2)8。Syst e m.e x i t(0);。)publi c stati c v o i d m a i n(S t ring a rg s)LoginB a c kPan e 1 lgp=n e w Logi n B ac kPa n e 1(管理系统登录);。Igp.s

8、etDe f aul t C lo s e O p e r ation(JF r ame.E X I T O N CLO S E);1 gp.setSize(300,20 0);Igp.s e t Lo c a t ion(5 5 0,25 0);o 1 gp.set V isible(t r u e);)c lass B S extends J Fra me imple m en t sA c t i o n L i stenerJ B u t ton B 1,B2,B3,B 4,B 5,B6,B7;C o n t ainer c t=getC o ntentPane();op u blic

9、 B S(String s tr)osu p er(str);o s etB a k();o J Pa n e 1 J P=new J Panel();eJP.setO p aque(fals e);c t.add(JP);J P.setLa y ou t(n e w Flow Layou t(F lo w L ay o u t.CE N TE R,30,50);sBl=n ew J B utton(销售情况)B2=new J B u tton(客户退货)B3=new JB u tto n(销售收款);。出 4=new J B u tto n(客户信息);也5=n e w J B u tto

10、n(员工管理);B6=new JBut t on(进货信息)B7=new JBut t on(更换角色);oB 1.a ddAc t io n L ist e n er(this);0B 2.ad d Ac tio n Liste n er(this);eB3.addAc tio n Lis t ener(t his);oB4.a d d A c ti o nL i stene r(this);o B 5.addAc t i o n L i st e ner(t h is);8B 6.addAc t i o nLi s t ene r(th i s);B7.addAc t i onLis t

11、e ner(this);J P.ad d(Bl);o J P.add(B 2);JP.add(B3);*J P.add(B4);J P.add(B5);gJP.add(B 6);gJP.a d d(B 7);oad d(JP);。pub 1 ic v o i d s e tBak()s(J P an e l)th i s.ge t C o ntentPa n e().setOp a que(f a 1 se);oo Imageic on i m g=n e w I magelc o n(e:数据库课程设计/六月物语 1-jpg);J Labe 1 ba c kgro u nd=ne w JL

12、a bel(i mg);o t h i s.getLa y ered P an e().ad d(b a c kground,new I n teger(I n te g er.MI N_VALU E);bac k g round.setBo u nds(0,0,img.getlc o nWi d th(),img.g e t I c on H eig h t();)*p ubli c v o id ac tionPe r fbrmed(Ac tio nEvente)i f(e.g e tS o u rc e()=B 1)this.di s po s e();CXFPXX c xfpxx=ne

13、w CXF P XX(日常销售一【发票情况】);o 0 c x fpx x.set S i z e(7 0 0,300);o o c xfpxx.s e t L oc a t io n(3 5 0,2 50);c xf p xx.s e tVisib 1 e(true);0)i f(e.g etSourc e()=B 2)s this.d i sp o se();0XSTHXXxsthxx=new XST H XX(日常销售一【销售退货】);。xs t hx x.s etSize(700,300);o xsthx x.s etLo c at ion(3 5 0,250);x st h xx.s

14、etV i sible(t rue);0 0 6if(e.g etSourc e()=B3)s this,d ispo s e();。XS X XC X xsx x c x=new XSXXC X(日常销售一【销售收款】);x sxx c x.setSiz e(700,300);x s xxc x.setLoc ation(3 5 0,250);xsxxc x.s e tVisib 1 e(true);oi f(e.getSo u rc e()=B 4)*o this.d i spos e();。H Y XXCX hyxxc x=new HYXXCX(基本信息管理一【会员信息】);o o h

15、y xxc x.s etSiz e(70 0,3 0 0);h y xxc x.s e t L o c ation(350,25 0);hyxxc x.s etVisible(true);ogif(e.g e t Sourc e()=B 5)o t his.d i s po s e();。YGGLyg g 1=new YGG L(员工管理一【员工信息】);yg g 1.s etS i ze(5 0 0,2 00);o yggl.s etL o c a t ion(4 50,2 5 0);yggl.setVis i b 1 e(tru e);oei f(e.get S ourc e()=B 6)

16、this,d i s p o se();。JHXXjhxx=new JH XX(商品更新一【进货信息】);0 j h xx.s e tSi z e(3 0 0,150);jhxx.s e tL o c ation(5 0 0,250);jhxx.s etVisi b le(true);。i f(e.g e tSourc e()=B 7)o t h is.d i s p o se();o o Log inBac k Pan e 1 xt=new Lo g inBac kPan e 1(管理系统登录);。x t.se t Size(30 0,2 0 0);xt.se t L o c ati o n

17、(5 5 0,25 0);x t.set V i s ibl e(t r u e);001)c lass BG 2 extends Abstrac t T ab 1 eM o d e 1Str i ng rq,ph,mc,bh,d j,si,je;fi n a 1 St r i ng c olumnNames=开票日期,销售票号,商品名称,商品 编号,商品单价/元销售数量/个,销售金额/元;Ob j ec tdata=ne w Obj e c t10 0 7;publ i c BG2()。int m=0;Str i n g url=jdbc:m ic r o soft:s q Iserve r

18、:/1 oc alhos t:1433;Da t ab a seName=课程设计;b Con n ec t i on c o n;S t ring s ql;S t a tement st m t;tr y o Cl a ss.forName(c o m.m ic rosoft.jdbc.s qls e rver.SQ L ServerDr i ver);s c a t c h(java.lang.C la s sNotFound E x c eption e)try o c on=Driv e r M a n a g er.ge t Conne c tion(u rL sa,12345 6

19、);stmt=c on.c r eateStatement();。sq 1=S EL E C T*FR 0 M 销售发票 Re s ultSe t rs=stmt.e xec ut e Q uery(s q 1);8 w hil e(rs.ne x t()oor q=rs.g e tStr i n g(1);8 ph=rs.getStr ing(2);8m c=r s.getStr i n g(3);ebh=r s.get S tring(4);o*d j=r s.getStr i ng(5);8%l=rs.g e t Str i ng(6);j e=rs.get S tring(7);dat

20、amO=r q;d a t a m 1=p h;d a t a m 2=m c;data m 3=bh;d a t a m4=dj;dat a m5=s 1;datam+6=je;6 o stmt.c lose();s c on.c lose();o c at c h(SQLE x c e p t i on e)yste m.out.p r in t ln(0);。)public intge tColumn C o u nt()8ret u r n c o lumn N a mes.1 en g t h;opubli c int getRow Co u n t()sretur n da t a

21、.leng t h;publ i c Str i n g getCo 1 umnN a m e(i nt c ol)o r etur n c olum n Namesc o 1;pu b lie Objec t getV a lueAt(i n t row,int c o 1)return dataro w c ol;)*p u b 1 i c v o id set Value At(Obje c t val u e,i n t row,int c o 1)o i n t numR o w s=g e tRow Co u nt();8 i nt nu m Cols=g etC o lumnCo

22、 u n t();8 f or(int i=0;inumRow s;i+)08f o r(i n t j=0;jn umCol s;j+)*8 System.o u t.pr i nt(+d a t ai j);bb 4)c lass CXFPXX ex t e n ds JFra m e i m pl e me n ts Ac t i o n L istener B G 2 bg2;J T a b le t;JB u tton b;JPa n el p;J Sc r ollPane s;p u b 1 ic CXFPX X(S t r i ng str)s upe r(s tr);set L

23、 ayout(new B orde r L a yo u t();o b=ne w JBu t t on(确定);b.ad d A c t i o n L i ste n e r(thi s);p=new J Pan e 1();p.a dd(b);bg2-new B G2();t=new J T a b le(b g 2);s=new J Sc rollPane(t);a dd(s,C ent e r);a dd(p,South);)public voi d a c ti o nPerforme d(Ac t ion E v e nt e)if(e.g e tS o u r c e()=b)

24、o thi s.dis p o se();BS ex f p x x=n ew BS(管理员界面);。c xfpx x.s e tSize(500,250);exfp x x.s e tLoc ation(4 5 0,2 5 0);c xfpxx.se t V i s i b le(t rue);。)c las s BG3 e x tend s A b s trac t T ab 1 eModel String r q,m c,yy,s l,je;f ina 1 St r i n g c olumnN a mes=退货日期商品名称,退货原因,退 货数量/件,退货金额/元;*0 bj e c t

25、 d a ta=new Objec t 10 0 5;public BG3()o int m=0;S tr i ng u r 1=j d bc:mic ro s o ft:s qlser v e r:/loc a 1 host:1433;Datab a seName=课程设计”;Connec tio n c on;String s q 1;s Statement s tmt;try8 Cla s s.forN a m e(c om.mic r o soft,j dbc.sqlserver.SQ L S e rver D rive r);o c at c h(java.1 ang.ClassNo

26、tFo u ndExc eption e)0)0 t ry(c on=Dri v e r M a n ag e r.getCo n nec tion(url,s a,12 3 4 5 6);s tmt=c on.c re a te S tatement();。s q 1=S ELE CT*FROM 退货记录;o Re s ul t S et rs=s t mt.exec ute Query(s q 1);w hil e(r s.next()8 r q=rs.getStr i ng(l);。m c=r s.g etSt ring(2);8。yy=rs.g e tS t r i ng(3);sl=

27、r s.g e t S tri n g(4);je=r s.getSt r i ng(5);8。data m 0=r q;dataml =mc;datam 2=y y;d a ta m 3 =s 1;da t am+4=j e;00 stm t.c lose();c on.c l o se();”c a t c h(SQLExc epti o n e),*S y stem.out.p ri n t 1 n(0);e)p u blic int getColu m n C ount()return c olumnN ame s.len g th;o p ublic in t getRo w Co

28、u nt()r e turn data.length;p ubl i c S t ring ge t C o 1 umnName(i nt c ol)re t ur n c olumnN ames c o 1;。pu b 1 i c 0 b j e c t g e tVa 1 u e A t(i n t ro w,int c o 1)r e t u m d a ta r o w c o 1;*pub 1 ic void s e tValu e At(Objec t v al u e,i nt row,in t c o 1)o int n umRow s=g e tR o w C ount();

29、8 i n t n umC o ls=g etCo 1 um nCount();s for(i nt i=0;in u mR o w s;i+)8fb r(i n t j=0;jnumCols;j+)8 0Sy s tern.o u t.pr i nt(+dat a i j);00 00)jc lass XS T H X X ext e n ds J Frame imple m ent s Ac t i o nListener B G 3b g 3;JTab 1 e t;J B utto n b;J P a n el p;J S c r ollPa n e s;p ublic XSTHXX(S

30、 trin g s t r)s u per(str);setLa y out(ne w B orderLayout();b=ne w J Button(确定);b.a d dAc tionLis t e n e r(thi s);p=new J Pa n el();ep.a d d(b);bg3=n ew B G3();t=new J T able(bg3);s=n e w JSc r o 1 1 P a n e(t);add(s,Center);。a d d(p,S o u t h);)p ublic void ac t i o n Performed(Ac t ionE vent e)if

31、ife.g e t S o u rc e()=b)this.d i s p ose();BS c xf p xx=new B S(管理员界面)。c x fpxx.setS i z e(50 0,250);ex f pxx.set Loc ation(45 0,250);c xf pxx.setV i si b 1 e(t r ue);)c lass BG4 ext ends Ab s t ra c tTab 1 e M ode 1 S tr i n g rq,mc,dj,sl,je;fin a 1 Str i n g c o 1 u mnNam e s=开票日期,商品名称,商品单价/元,销 售

32、数量/个,销售金额/元;Objec t data=n e w Objec t 100 5;p u blic BG4()Mnt m=0;s S t r i n g ur 1=jd b c:m ic r o soft:s qlse r ver:/lo c al h os t:1 4 33;D at a b a seNa m e=课程设计;Conn e c t i on c o n;String sq 1;o Stateme n t st m t;try(Class.forName(c o m.m i c r os o ft.j db c,sq 1 se r v er.SQLServerDr i v

33、 e r);c at c h(j a v a.lan g.Class N otFo u n dE x c eption e)0 t ry(c o n=Dri v e rMa n ag e r.ge t C onnec tio n(u r 1,sa,123456);stmt=c on.c reate S tatem e nt();。sql=SE L E C T 开票日期,商品名称,商品单价/元,销售数量/个,销售金额/元FR。M 销售发票;b R esult S et r s=stm t.exec u t eQuery(sql);w hile(r s.n e x t()r q=rs.get St

34、ring(1);8mc=rs.getStr i n g(2);odj=rs.getS t r in g(3);o s l=rs.get S t rin g(4);。叫e=rs.get S t ring(5);da t am 0=rq;d a t aml mc;datam 2=d j;d ata m 3 =s 1;data m+4=je;0)s stmt,c lose();c o n.c 1 o s e();o)c at c h(S Q LE x c e p tio n e)Sy s tem.ou t.p rintln(0);0。*public intget ColumnC o un t()o

35、retur n c ol u mnNames.le n gth;public in t g et R ow C o unt()o ret u m dat a.leng t h;pu b 1 i c S t ring getCo 1 um n Name(i n t c ol)。re t u r n c o lum n N am e s c o 1;0p ublic 0 b j e c t getVa 1 ue A t(i n t r o w,in t c ol)8 r e t urn d at a r o w c ol;publ i c vo i d s e tValueAt(Ob j e c

36、t value,i n t r o w,int c o 1)gint n u m R ow s=g et R ow C o unt();int n u m C o Is=g etCol u mn C ount();o f o r(inti=O;i n umRow s;i+)fbr(i n t j=0;j n umCols;j+)*S ystem.o u t.p r i n t(+dat a ij);000 0 o40)c lass XSXX C X ex t ends J F ra m e i m pl e ments Ac ti o nListen e r BG 4 b g4;J T a b

37、 1 e t;JBu t t o n b;J P anel p;J S c rollPane s;p u bl i c XSXX CX(S t ring s t r)super(st r);s e t L ayou t(new Bord erL a y o ut();b=ne w JButto n(确定);b.add Ac t i on L i s ten e r(thi s);p=n e w J Panel();p.add(b);bg4=new B G4();et=new JTable(b g4);s=n e w JSc r o 1 IPane(t);o a dd(s,Center);。a

38、dd(p,So u th);)public void ac tionPerfbrmed(Ac t i o nEvent e)if(e.get S ourc e()=b)o this.d i s p o s e();s BS ex f pxx=n e w B S(管理员界面);o exf p xx.se t S i z e(500,250);exfp x x.setLo c at ion(45 0,2 5 0);c x fpx x.s e tV i s i b 1 e(t r ue);。)c lass B G 5 e xtends Abstrac t T ableMo d el S t ring

39、 c h,lx,d z,rq;fina 1 S t ring c olumnNames=客户称呼J联系方式,客户地址,入会日 期;Obje c t data=new 0 b j e c t10 0 4;publi c B G5()i n t m=0;s String url=jdbc:mic r o s oft:sqls e rver:/loc alhost:14 3 3;D a t a b a s eNa m e=课程设计;b Con n e c tion c on;*S trin g s ql;o S t atemen t stmt;0 t r y*Class.fbrN a me(c om

40、.m i c roso f t.j db c.sqls e rve r.SQL S erv e rDr i ve r);s c atc h(jav a.lang.Cl a ss N otFoundEx c eption e)。try(o c o n=Dri v e r M ana g e r.getCon n e c t i on(url,sa,1 2 3 45 6);s stmt=c o n.c r e a te S ta t ement();。s q 1=SELE CT*FROM 客户信息;o Res u ItSet rs=s t m t.ex e c uteQuery(s q 1);8

41、w hi 1 e(rs.next()o c h=r s.ge t Strin g(1);lx=rs.g etStri n g(2);8 dz r s.getS t ring(3);s r q=rs.getStri n g(4);o d a tam 0=c h;d a t a m 1=1 x;datam 2 =dz;data m+3=r q;00 8 s t m t.c lose();s c on.c 1 os e();oc a t c h(S Q L E xc e ption e)Syste m.o u t.p r i n t 1 n(0);。p ubli c i nt ge t Column

42、Count()r e turn c o lumnNames.length;。*p u b 1 ic int getRo w C o unt()s r e turn data,length;0)public St r ing getCo 1 u m nNam e(int c ol)o r etur n c o lu m n Namesc o 1;*p u blic 0 bjec t g e tValueAt(int r o w,i n t c ol)sret u r n dat a r o w c ol;p ubl i c void s e tValu e At(O b jec t val u

43、e,int ro w,i n t c ol)o i n t n umRow s=getRow C o unt();int n umC o ls=ge t Co 1 umnCo u n t();8 f or(int i=0;in u mRow s;i+)f o r(i nt j=0;jif(e.getSo u rc e()=B1)s t h is.d i s pose();。T J Y G t j y g=new TJ Y G(员工管理一【添加员工】);tjyg.se t S i z e(40 0,35 0);o t j y g.s etLo c ati o n(4 5 0,200);t j y

44、 g.s e t Visible(true);0 时 f(e.get S our c e()=B 2)s t h is.dispos e();。SCYG sc y g=new S C YG(员工管理一【删除员工】);o o sc yg.se t Siz e(30 0,150);o sc yg.s e t L o c a t ion(5 5 0,3 0 0);s c y g.s e tV i si b le(t rue);0 o ifife.get S o u rc e()=B 3)o t h i s.di s p o s e();。Y GMDXX yg m dxx=n ew YGMDXX(员工

45、管理一【员工名单】);y g mdx x.setSi z e(700,3 0 0);s ygmdx x.s e tLoc a ti o n(3 5 0,2 5 0);y g m d x x.setVi s ible(tr u e);0 6。if(e.get S o u r c e()=B4)this,d i spose();。G X X X gxxx=new G X XX(员工管理一【更新信息】);g x xx.setSize(30 0,200);。g xx x.se t L oc atio n(5 00,2 5 0);g x xx.s e t V isible(true);o b 8 i f

46、(e.getSourc e()=B5)t h i s.dis p ose();B S bs=new BS(管理员界面);。b s.s e tS i z e(500,250);b s.setLoc a t i on(450,250);bs.s e t V i s i b 1 e(t r ue);o)c l a ss TJYG e x tends JF r ame imple m e nts Ac t io n List e n e r oJLabel L 1,L2,L3,L 4,L 5;J T e xt F i e 1 dTl,T 2,T3,T 4,T 5;J B utton BL B2;Co

47、n t ai n er c t=getCon t ent P ane();o p ub 1 ic TJ Y G(String s t r)ssupe r(str);setBa k();o J P a n el p an e 1=new JPanelQ;opan e 1.s etO p aq u e(false);8P a nel.se t L ay o ut(n ew F 1 o w La you t(Fl o w L ayou t.C ENTER,6 0,25);*L 1=new J Labe 1(员工名称:);L2=new J La b el(员工编号:);0L3=n e w JL a b

48、el(员工职位:);oL4=n ew J Lab e 1(聘请日期:);8L5=n e w J L abel(联系方式:);。Tl=n e w J Tex t F i e Id(10);8T2=new JTextField(lO);*T3=ne w J TextField(lO);oT4=new JT extFi e ld(10);oeT 5=new J Text F i e 1 d(1 0);*B 1=ne w JBu t to n(确定)。B2=new J Butt o n(返回);B 1.addAc ti o nLi s t ener(t his);0B2.ad d Ac t io n

49、List e ner(t h is);panel.ad d(L 1);panel.add(Tl);pa n el.a d d(L 2);pane 1.add(T2);oop a n e 1.a dd(L3);pane l.add(T 3);pan e 1.add(L 4);ep a ne 1.add(T 4);p an e Lad d(L5);panel.add(T5);p a n e 1.a d d(B 1);panel.a d d(B2);8 a dd(pa n el);。pu b lie v oid s et B ak()(JP a ne 1)t his.get C o nt e ntP

50、ane().setOpa q ue(f alse);I m a g eic on i m g=new Ima g e Ic on(e:/数据库课程设计六月物语2.jpg);*J L a b el ba c kground=n e w JLa b e 1(img);thi s.g e t L ay e redPaneC).add(bac kgr o u n d,n e w I n tege r(In t e g er.M IN_ V A L UE);bac kgroun d.setBou n ds(O,0,img.getIc onWidth(),img.getlc o n H eight();o

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 管理财经 > 质量控制/管理

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服