ITPub博客

首页 > 数字化转型 > ERP > JSP(8) - 按卡号查询顾客信息

JSP(8) - 按卡号查询顾客信息

原创 ERP 作者:zhyuh 时间:2005-06-14 21:26:36 0 删除 编辑

分两页。第一页提示用户输入顾客卡号,第二页根据卡号返回顾客详细信息。由于卡号位一确定某位顾客,故该顾客的交易信息也同时返回。

要点:
1) 根据返回纪录动态生成表格
out.println("");
out.println(""+sCustId+"");
out.println(""+sCustName+"");
......

2) 若某字段结果为空,则应付值  ,以避免生成的表格缺边框
sCustEmail = rs.getString("cst_email");
if (sCustEmail==null) sCustEmail=" ";

[@more@]

源程序

qry_cust_id1.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>







顾客信息查询







<!--

-->





按顾客卡号查询


请输入顾客卡号: 


         





qry_cust_id2.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
java.util.Date d = new java.util.Date();
DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE);
%>






顾客信息查询




<%
String sCustId = request.getParameter("cust_id");

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl???????SID
String user="store";
String password="store";
Connection conn= DriverManager.getConnection(url,user,password);
ResultSet rs = null;
String sQuery = null;
Statement stmt = null;

%>

顾客信息



















<%
try {
String sCustName = "";
String sCustSex = "";
String sCustYear = "";
String sCustMonth = "";
String sCustAddress = "";
String sCustZipCode = "";
String sCustPhOffice = "";
String sCustPhHome = "";
String sCustMobile = "";
String sCustEmail = "";
String sCustDisc = "";
String sCustTtSum = "";
String sCustCrtDt = "";
String sCustUptDt = "";


sQuery = "select cst_id, cst_name,decode(cst_sex,'M','男','F','女',cst_sex) cst_sex, cst_year, cst_month, cst_address, cst_zip_code, ";
sQuery = sQuery + "cst_ph_office, cst_ph_home, cst_mobile, cst_email, cst_discount, cst_trd_sum, ";
sQuery = sQuery + "to_char(cst_crt_date,'yyyy-mm-dd') cst_crt_date, ";
sQuery = sQuery + "to_char(cst_upt_date,'yyyy-mm-dd') cst_upt_date from customer where cst_id = '"+sCustId+"'";

stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);

while(rs.next())
{
sCustId = rs.getString("cst_id");
sCustName = rs.getString("cst_name");
sCustSex = rs.getString("cst_sex");
sCustYear = rs.getString("cst_year");
if (sCustYear==null) sCustYear="";
sCustMonth = rs.getString("cst_month");
if (sCustMonth==null) sCustMonth="";
sCustAddress = rs.getString("cst_address");
if (sCustAddress==null) sCustAddress=" ";
sCustZipCode = rs.getString("cst_zip_code");
if (sCustZipCode==null) sCustZipCode=" ";
sCustPhOffice = rs.getString("cst_ph_office");
if (sCustPhOffice==null) sCustPhOffice=" ";
sCustPhHome = rs.getString("cst_ph_home");
if (sCustPhHome==null) sCustPhHome=" ";
sCustMobile = rs.getString("cst_mobile");
if (sCustMobile==null) sCustMobile=" ";
sCustEmail = rs.getString("cst_email");
if (sCustEmail==null) sCustEmail=" ";
sCustDisc = rs.getString("cst_discount");
if (sCustDisc==null) sCustDisc=" ";
sCustTtSum = rs.getString("cst_trd_sum");
sCustCrtDt = rs.getString("cst_crt_date");
sCustUptDt = rs.getString("cst_upt_date");

out.println("

");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
}

}

catch (Exception e){
System.out.println("顾客信息查询失败!");
e.printStackTrace();
out.println("

顾客信息查询失败!

");
out.println( e.getMessage() );
}

%>

卡号 姓名 性别 出生年月 折扣 购物总额 email 手机 办公室电话 家庭电话 通讯地址 邮编 创建日期 最后修改日期 姓名 卡号
"+sCustId+""+sCustName+""+sCustSex+""+sCustYear+"年"+sCustMonth+"月"+sCustDisc+"%"+sCustTtSum+"元"+sCustEmail+""+sCustMobile+""+sCustPhOffice+""+sCustPhHome+""+sCustAddress+""+sCustZipCode+""+sCustCrtDt+""+sCustUptDt+""+sCustName+""+sCustId+"




该顾客交易信息











<%
try {
String sExchDate = "";
String sExchSeq = "";
String sExchType = "";
String sExchCommName = "";
String sExchQutt = "";
String sExchCommUnit = "";
String sExchMon="";

sQuery = "select to_char(exch_date,'yyyy-mm-dd') exch_date, exch_seq, ";
sQuery = sQuery + "decode(exch_type,'A','总公司的发货单','B','本店制作的退货单','C','销货发票','D','购买','E','退货','F','处理',exch_type) exch_type, ";
sQuery = sQuery + "comm_name, exch_nb, comm_unit, exch_mon from exchange e, commodity c ";
sQuery = sQuery + "where e.exch_comm_id=c.comm_id and exch_cst_id = '"+sCustId+"' order by exch_date desc, exch_seq asc";

stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);

while(rs.next())
{
sExchDate = rs.getString("exch_date");
sExchSeq = rs.getString("exch_seq");
sExchType = rs.getString("exch_type");
sExchCommName = rs.getString("comm_name");
if (sExchCommName==null) sExchCommName="";
sExchQutt = rs.getString("exch_nb");
sExchCommUnit = rs.getString("comm_unit");
sExchMon = rs.getString("exch_mon");

out.println("

");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
out.println("
");
}

rs.close();
stmt.close();
conn.close();
}

catch (Exception e){
System.out.println("交易信息查询失败!");
e.printStackTrace();
out.println("

交易信息查询失败!

");
out.println( e.getMessage() );
}

finally{
if(stmt != null) stmt.close();
conn.close();
}

%>



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/207/viewspace-800199/,如需转载,请注明出处,否则将追究法律责任。

上一篇: JSP(7) - 销售模块
请登录后发表评论 登录
全部评论
  • 博文量
    233
  • 访问量
    2008671
交易日期 当日序号 交易类型 商品 数量 单价 金额
"+sExchDate+""+sExchSeq+""+sExchType+""+sExchCommName+""+sExchQutt+""+sExchCommUnit+"元"+sExchMon+"元