网上书店完整代码.docx

上传人:b****3 文档编号:24790866 上传时间:2023-06-01 格式:DOCX 页数:18 大小:17.33KB
下载 相关 举报
网上书店完整代码.docx_第1页
第1页 / 共18页
网上书店完整代码.docx_第2页
第2页 / 共18页
网上书店完整代码.docx_第3页
第3页 / 共18页
网上书店完整代码.docx_第4页
第4页 / 共18页
网上书店完整代码.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

网上书店完整代码.docx

《网上书店完整代码.docx》由会员分享,可在线阅读,更多相关《网上书店完整代码.docx(18页珍藏版)》请在冰豆网上搜索。

网上书店完整代码.docx

网上书店完整代码

附录全部源代码

packageclassConnect{

privatestaticConnectioncon=null;

privatestaticStringurl="jdbc:

oracle:

thin:

@localhost:

1521:

ORCL";

privatestaticStringdriver="";

privatestaticStringuser="scott";

privatestaticStringpwd="tiger";

publicstaticConnectiongetConnection(){

try{

(driver);

con=(url,user,pwd);

"数据库连接成功!

");

}catch(ClassNotFoundExceptione){

"驱动加载失败!

");;

}catch(SQLExceptione){

"数据库连接失败!

");

}

returncon;

}

publicstaticvoidmain(String[]args){

();

}

}

packageclassdocMenuActionimplementsActionListener{

RegisterFrameregister=null;

JPanelcusPanel=null;

JPaneldocPanel=null;

publicdocMenuAction(RegisterFrameregister){

=register;

=;

=;

}

publicvoidactionPerformed(ActionEvente){

于用户搜索商品

publicArrayListgetAllSellerGoods(){

ArrayListlist=newArrayList();

conn=();

try{

statement=();

Stringsql="select*fromgoodsa,sellerbwhere=";

resultSet=(sql);

while()){

Sellerseller=newSeller();

("seller_name"));

("address"));

Goodsgoods=newGoods();

(seller);

("goods_id"));

("goods_name"));

("seller_id"));

("discount"));

("num"));

("price"));

2012-9-192012-9-192012-9-192012-9-19etImage());

(null);

(null);

(false);

etImage());

(600,400);

;

(null);

(menuBar,;

setGoodsPanel();

;

(goodsPanel,;

;

setSouthPanel();

setOrderPanel();

(southPanel,;

}

quals())){

(null,"请输入商品编号或商品数量!

");

}else{

intid=());

intnum=((String)());

goods=(id);

if(null,"您确定要购买吗")==0){

if()==0){

(null,"商品编号输入错误!

");

}else{

if()

(null,"商品数量不足!

");

}else{

()-num);

(goods);

OrderDaoorder=newOrderDao();

(goods,num);

(null,"购买成功!

");

setAr();

setOr();

();

}

}

}else{

}

}

}

});

}

etName();

ar[i][7]=().getAddress();

}

}

privatevoidsetArNull(){

for(inti=0;i<;i++){

for(intj=0;j

ar[i][j]="";

}

}

}

etName();

or[i][3]=().getPrice();

or[i][4]=().getDiscount();

or[i][5]=().getPrice()*().getDiscount()*;

or[i][6]=();

or[i][7]=().getName();

or[i][8]=().getAddress();

}

}

privatevoidsetOrNull(){

for(inti=0;i<;i++){

for(intj=0;j

or[i][j]="";

}

}

}

publicstaticvoidmain(String[]args){

BuyerFrameframe=newBuyerFrame();

(true);

}

}

 

packageclassLoginFrameextendsJFrame{

privateJLabeluserNameLabel=newJLabel("用户名:

");

privateJLabelpwdLabel=newJLabel("密码:

");

privateJTextFielduseNameText=newJTextField();

privateJPasswordFieldpws=newJPasswordField();

privateJLabelroleLabel=newJLabel("角色:

");

privateJComboBoxroleBox=newJComboBox(newString[]{"商家","买家"});

privateJButtonbt=newJButton("确定");

privateJButtonbtR=newJButton("取消");

privateStringflag=null;

publicLoginFrame(){

init();

}

privatevoidinit(){

(320,280);

("登录");

(newImageIcon("images/").getImage());

(null);

(false);

;

(null);

(40,20,150,30);

(userNameLabel);

(120,20,150,30);

(useNameText);

(40,80,150,30);

(pwdLabel);

(120,80,150,30);

(pws);

(40,140,70,30);

(roleLabel);

(120,140,150,30);

(roleBox);

(40,200,70,30);

(btR);

(newActionListener(){

@Override

publicvoidactionPerformed(ActionEvente){

quals(f)){

flag="seller";

}

if("买家".equals(f)){

flag="customer";

}

if("seller".equals(flag)){

Sellerseller=(),());

"-----"+());

if()==null){

(null,"用户名或密码输入错误");

}else{

setVisible(false);

SellerFramefame=newSellerFrame();

(true);

}

}if("customer".equals(flag)){

Buyerbuyer=(),());

if()==null){

(null,"用户名或密码输入错误");

}else{

setVisible(false);

BuyerFrameframe=newBuyerFrame();

(true);

}

}

2012-9-20etImage());

(300,400);

etImage());

(600,400);

;

(null);

(menuBar,;

setGoodsPanel();

;

(goodsPanel,;

;

setSouthPanel();

setOrderPanel();

(southPanel,;

}

quals())){

(null,"请输入商品编号!

");

}else{

intid=());

UpdateFrameframe=newUpdateFrame();

Goodsgoods=newGoodsDao().getOneGoods(id);

if()!

=0){

(goods);

(goods);

(true);

}else{

(null,"商品编号输入错误!

");

}

}

}

});

(btDelet);

quals())){

(null,"请输入商品编号!

");

}else{

intid=());

GoodsDaodao=newGoodsDao();

if(null,"您确定要删除吗")==0){

if(id)!

=0){

(null,"删除成功!

");

}else{

(null,"商品编号输入错

误!

");

}

}else{}

}

}

});

(btAdd);

(newActionListener(){

@Override

publicvoidactionPerformed(ActionEvente){

etName();

ar[i][7]=().getAddress();

}

}

privatevoidsetArNull(){

for(inti=0;i<;i++){

for(intj=0;j

ar[i][j]="";

}

}

}

etName();

or[i][3]=().getPrice();

or[i][4]=().getDiscount();

or[i][5]=().getPrice()*().getDiscount()*;

or[i][6]=();

or[i][7]=();

}

}

privatevoidsetOrNull(){

for(inti=0;i<;i++){

for(intj=0;j

or[i][j]="";

}

}

}

publicstaticvoidmain(String[]args){

SellerFrameframe=newSellerFrame();

(true);

}

}

 

packageclassUpdateFrameextendsJFrame{

privatestaticfinalGoodsGoods=null;

privateJLabellbName=newJLabel("商品名:

");

privateJLabellbPrice=newJLabel("价格:

");

privateJLabellbDiscount=newJLabel("折扣:

");

privateJLabellbNum=newJLabel("数量:

");

privateJTextFieldfieldName=newJTextField(20);

privateJTextFieldfieldPrice=newJTextField(20);

privateJTextFieldfieldDiscount=newJTextField(20);

privateJTextFieldfieldNum=newJTextField(20);

privateJButtonbtSure=newJButton("修改");

privateJButtonbtCancel=newJButton("取消");

privateGoodsgoods=newGoods();

publicUpdateFrame(){

init();

}

privatevoidinit(){

(320,330);

("修改商品信息");

(newImageIcon("images/").getImage());

(null);

(null);

(false);

//;

(null);

setText(goods);

setContentPanel();

}

privatevoidsetContentPanel(){

(30,30,80,30);

(130,30,150,30);

(30,90,80,30);

(130,90,150,30);

(30,150,80,30);

(130,150,150,30);

(30,200,80,30);

(130,200,150,30);

(30,250,70,30);

(210,250,70,30);

(lbName);

(fieldName);

(lbPrice);

(fieldPrice);

(lbDiscount);

(fieldDiscount);

(lbNum);

(fieldNum);

(btCancel);

(btSure);

(newActionListener(){

@Override

publicvoidactionPerformed(ActionEvente){

//TODOAuto-generatedmethodstub

setVisible(false);

}

});

(newActionListener(){

@Override

publicvoidactionPerformed(ActionEvente){

//TODOAuto-generatedmethodstub

if(null,"您确定要修改吗")==0){

GoodsDaodao=newGoodsDao();

()));

());

()));

()));

(goods);

setVisible(false);

(null,"修改成功!

");

}else{

//

}

}

});

}

publicvoidsetText(Goodsgoods){

());

()));

()));

()));

}

publicGoodsgetGoods(){

returngoods;

}

publicvoidsetGoods(Goodsgoods){

=goods;

}

publicstaticvoidmain(String[]args){

UpdateFrameframe=newUpdateFrame();

(true);

}

}

数据库SQL语句:

createtableseller(

seller_idvarchar2(20)primarykey,

seller_namevarchar2(20),

pwdvarchar2(20),

addressvarchar2(200)

insertintosellervalues('niclascage','长理专卖店','123456','湖南长沙')

select*fromseller

droptableseller

commit

createtablebuyer(

buyer_idvarchar(20)primarykey,

buyer_namevarchar(20),

pwdvarchar2(20),

addressvarchar(200)

insertintobuyervalues('lina','林大专卖店','123456','湖南长沙')

select*frombuyer

droptablebuyer

createtablegoods(

goods_idintprimarykey,

seller_idvarchar(20),

goods_namevarchar(50),

priceint,

discountint,

numint,

constraintfk_seller_idforeignkey(seller_id)referencesseller(seller_id)

insertintogoodsvalues(1,'niclascage','Java',40,8,20)

select*fromgoods

droptablegoods

createtableorders(

order_idintprimarykey,

goods_idint,

seller_idvarchar(20),

buyer_idvarchar(20),

numint,

constraintfk_goods_idforeignkey(goods_id)referencesgoods(goods_id),

constraintfk_sellers_idforeignkey(seller_id)referencesseller(seller_id),

constraintfk_buyer_idforeignkey(buyer_id)referencesbuyer(buyer_id)

select*fromorders

insertintoordersvalues(1,1,'niclascage','lina',2)

droptableorders;

droptablegoods;

droptablebuyer;

droptableseller;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 其它考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1