学术论文网
在线图书销售管理系统
发布日期:2024-11-02 21:09:28

  第5章 详细设计

  5.1会员注册

  输入会员信息,并点击注册,会员登陆名不能重复,密码不能小于六位,主要代码如下:

  String name=request.getParameter("name");

  String sex=request.getParameter("sex");

  String age=request.getParameter("age");

  String tel=request.getParameter("tel");

  String address=request.getParameter("address");

  String mail=request.getParameter("mail");

  String xueli=request.getParameter("xueli");

  String login=request.getParameter("login");

  String pass=request.getParameter("pwd1");

  //out.print(String.format("姓名:%s,性别:%s,年龄:%s,电话:%s,地址:%s,邮箱:%s,专业:%s,学历:%s,登陆名:%s,密码:%s",name,sex,age,tel,address,mail,zhuanye,xueli,login,pass));

  //return;

  if(new ClientServer().Login(login)!=null)

  {

  out.print("");

  return;

  }

  Client vip=new Client();

  vip.setName(name);

  vip.setSex(sex);

  vip.setAge(Integer.parseInt(age));

  vip.setTel(tel);

  vip.setAddress(address);

  vip.setMail(mail);

  vip.setXueLi(xueli);

  vip.setLogin(login);

  vip.setPass(pass);

  int count=new ClientServer().Add(vip);

  if(count==0)

  out.print("");

  else

  out.print("");

  6.2图书列表

  用户可以查看所有本站的图书信息

  关键功能代码如下:

  int startindex=0;

  if(request.getParameter("startindex")!=null)

  startindex = Integer.parseInt(request.getParameter("startindex"));

  int pagesize=20;

  String key=" 1=1 and";

  if(request.getParameter("ttID")!=null)

  key+=" ThingType_ID="+request.getParameter("ttID")+" and";

  if(request.getParameter("title")!=null&&request.getParameter("title").length()>0)

  key+=" title like '%"+new String(request.getParameter("title").getBytes("ISO-8859-1"), "UTF-8")+"%' and";

  key=key.substring(0,key.length()-3);

  int rcount=new ThingServer().GetCount(key);

  List ts=new ThingServer().GetAll(key,startindex,pagesize);

  request.setAttribute("ts", ts);

  6.3图书信息

  用户可以查看所有图书的详细信息,主要实现功能代码如下:

  

您现在的位置:图书明细

 

  <%

  int id=Integer.parseInt(request.getParameter("id"));

  Thing t=new ThingServer().GetByID(id);

  %>

  

 

  

 

  

 

  

<%=t.getTitle() %>

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

  • 图书类型:<%=t.getType().getType() %>
  • 作者:<%=t.getAuthor() %>
  • 出版社: <%=t.getShe() %>
  • ISBN:<%=t.getIsbn() %>
  • 单价:<%=t.getPrice() %>元
  •  

      

      

 

  

 

  

  

 

  

图书介绍

  <%=t.getContent() %>

  

 

  

 

  6.4 发布图书

  填写商品的详细信息,然后点击提交,关键代码为:

  request.setCharacterEncoding("UTF-8");

  //上传代码

  com.jspsmart.upload.SmartUpload smart=new com.jspsmart.upload.SmartUpload();

  String filename = "";

  if(request.getParameter("param")==null||"".equals(request.getParameter("param")))//删除

  {

  //初始化的方法必须先执行

  //参数:config,request,response都是jsp内置对象

  smart.initialize(config,request,response);

  smart.upload();

  //取得整个web应用的物理根路径(注意不是jsp项目根路径)

  String root = request.getSession().getServletContext().getRealPath("/");

  //设置上传文件的保存路径(绝对路径/物理路径)

  String savePath = root + "file\\";

  //声明SmartUpload类对象

  try {

  //将全部上传文件保存到指定目录下

  smart.save(savePath);

  //取得文件名(因为只上传一个文件,所以用getFile(0))

  filename = smart.getFiles().getFile(0).getFileName();

  } catch (Exception e){

  System.out.println("Error : " + e.toString());

  }

  }

  //上传结束

  //out.print(smart.getRequest().getParameter("content"));

  String title=smart.getRequest().getParameter("title");

  String price=smart.getRequest().getParameter("price");

  String content=smart.getRequest().getParameter("content");

  String id= request.getParameter("id");

  String typeID= smart.getRequest().getParameter("thingtype");

  String param=request.getParameter("param");

  Thing d=new Thing();

  if(param==null)

  {

  d.setTitle(title);

  d.setContent(content);

  d.setPrice(Integer.parseInt(price));

  d.setImg("");

  if(!"".equals(filename))

  d.setImg("file/"+filename);

  else if(id!=null&&!"null".equals(id))

  {

  Thing o=new ThingServer().GetByID(Integer.parseInt(id));

  d.setImg(o.getImg());

  }

  }

  //String sql=String.format("insert Thing values('"+d.getTitle()+"',"+d.getPrice()+",'"+d.getImg()+"','"+d.getContent()+"',"+typeID+")");

  //out.print(sql);

  int count=0;

  if(id==null||id.equals("null"))

  count = new ThingServer().Add(d,Integer.parseInt(typeID));

  else if(param==null)

  {

  d.setId(Integer.parseInt(id));

  count=new ThingServer().Edit(d,Integer.parseInt(typeID));

  }

  else if(param.equals("del"))

  count=new ThingServer().Del(Integer.parseInt(id));

  if(count==0)

  out.print("");

  else

  out.print("");

  6.5 订单信息管理

  可以查看本站所有订单,关键代码为:

  int startindex=0;

  if(request.getParameter("startindex")!=null)

  startindex = Integer.parseInt(request.getParameter("startindex"));

  int pagesize=20;

  int rcount=new DingServer().GetCount("");

  List ds=new DingServer().GetAll("",startindex,pagesize);

  request.setAttribute("ds", ds);

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

  

订单编号 会员姓名 联系电话 送货地址 购买日期 订单总额 查看记录
${ d.id } ${ d.client.name } ${ d.client.tel } ${ d.client.address } ${ d.intime } ${ d.sum }

 

  购物明细

  

 

  6.6购物车的实现

  会员可以一次购买多个商品,可以先把商品放入购物车,确定之后再点生成订单即购买成功,主要代码如下:

  request.setCharacterEncoding("UTF-8");

  String param=request.getParameter("param");

  if("add".equals(param))

  {

  List ts=new ArrayList();

  if(session.getAttribute("buy")!=null)

  {

  ts=(List)session.getAttribute("buy");

  }

  int id=Integer.parseInt(request.getParameter("id"));

  Thing t=new ThingServer().GetByID(id);

  t.setNum(1);//默认购买一个

  ts.add(t);

  session.setAttribute("buy",ts);

  out.print("");

  }

  else if("del".equals(param))

  {

  int id=Integer.parseInt(request.getParameter("id"));

  List ts=(List)session.getAttribute("buy");

  for(int i=0;i

  {

  if(ts.get(i).getId()==id)

  ts.remove(i);

  }

  session.removeAttribute("buy");

  session.setAttribute("buy",ts);

  out.print("");

  }

  6.7推荐模块

  主要实现功能代码如下:

  <%

  List tj=new ThingServer().GetAll("ThingType_ID="+t.getType().getId()+" and ID<>"+id,0,4);

  request.setAttribute("tj", tj);

  %>

  

推荐图书

 

  

 

  

  

 

  

  

 

  第7章 总结

  本次毕业设计,收获颇多,积累了丰富的JSP平台下编程的经验,并对数据库设计有了进一步解,设计、配置起来更加熟练,为以后项目实施打下了坚实基础。

  从需求分析开始,一步步走完了软件开发的整个流程,对软件开发有了更深层次的认识,本系统从开始到结束一共经历了两个多月,基本完成应该实现的功能,在此期间查阅过大量资料,并得到指导老师无私的帮助,因此才有现在这般完整的系统呈现在大家面前,但是由于时间上种种原因导致系统可能不够美观等,希望老师们谅解。

  通过本次毕业设计,提高了我开发数据库应用程序的能力,熟悉和运用现代数据库开发的工具和方法。使我迅速掌握了数据库应用程序的相关技术,为以后开发大型应用程序打下了基础。本次毕业设计还使我了解到数据库基本开发技术不外乎数据的增、删、改、查,其难度并不复杂,但是要想开发出理想的数据库应用程序,关键是软件的创意,要发挥想象力,设计出有个性的功能和用户界面。

 3/3     1 2 3
Copyright © 2008-2020 学术论文网 版权所有 粤ICP备16093775号