<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="net.sz600.tool.*" %>
<%@ page import="net.sz600.database.*" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.drivingSchool.*" %>
<%//@ include file="/sessionInfo.jsp"%>
<%
	String cardid = SzConvert.toSpaceStr(request.getParameter("cardid"));
	String name = SzConvert.toSpaceStr(request.getParameter("name"));

	String key = SzConvert.toZeroStr(request.getParameter("key"));
	String liushuihao = SzConvert.toSpaceStr(request.getParameter("liushuihao"));
	//取的部门限制的
	SzDataReader dataReader = new SzDataReader();

	//String name = "";
	String number = "";
	String depart = "";
	String id = "0";
	String tel = "";
	String mobile = "";

	//姓名XXMC2, 身份证XXMC3, 合同编号XXMC4, 报名点名称XXMC5, 历次应收合计XXMC18 ,历次已收合计XXMC19, 欠款合计XXMC20, 学员ID XXMC21, 报名点ID XXMC22

	//BD_DRIVINGSCHOOL_XUEYUAN:姓名XXMC2, 身份证XXMC8, 合同编号XXMC72, 报名点名称XXMC6,  学员ID XXMC1, 联系电话 XXMC7, 移动电话 XXMC69
        String sCond = "";
        if (!cardid.equals("")) {
          sCond = "XXMC8<>'' and XXMC8='" + cardid + "'";
        } else if (!name.equals("")) {
          sCond = "XXMC2<>'' and XXMC2='" + name + "'";
        }

        ResultSet rs = dataReader.readInfo("BD_DRIVINGSCHOOL_XUEYUAN", "XXMC2,XXMC72,XXMC6,XXMC1,XXMC7,XXMC69,XXMC8", sCond);
	StringBuffer sb = new StringBuffer("");
	if (rs != null && rs.next()) {
		name = SzConvert.toSpaceStr(rs.getString("XXMC2"));
		number = SzConvert.toSpaceStr(rs.getString("XXMC72"));
		depart= SzConvert.toSpaceStr(rs.getString("XXMC6"));
		id = SzConvert.toSpaceStr(rs.getString("XXMC1"));
		tel = SzConvert.toSpaceStr(rs.getString("XXMC7"));
		mobile = SzConvert.toSpaceStr(rs.getString("XXMC69"));
		cardid = SzConvert.toSpaceStr(rs.getString("XXMC8"));
	}
	if (!name.equals("") && !id.equals("0")) {

		//收据流水号
		if (liushuihao.equals("")) {
		  liushuihao = SzKey.getInstance().genNextKey("DRIVINGSCHOOL_LIUSHUIHAO","","yyyyMMdd",4);
		}

		//取合计
		Charge charge = new Charge();
		String sCharge[] = charge.getChargeByStudentId(id);	
		String sCharge2[] = charge.getChargeByStudentIdExcept(id, key);	

		sb.append("Begin;");
		sb.append(name);
		sb.append(";");
		sb.append(number);
		sb.append(";");
		sb.append(depart);
		sb.append(";");
		sb.append(id);
		sb.append(";");		
		sb.append(liushuihao);
		sb.append(";");
		sb.append(SzConvert.toZeroStr(sCharge[0]));
		sb.append(";");
		sb.append(SzConvert.toZeroStr(sCharge[1]));
		sb.append(";");
		sb.append(SzConvert.toZeroStr(sCharge[2]));
		sb.append(";");
		sb.append(SzConvert.toZeroStr(sCharge2[0]));
		sb.append(";");
		sb.append(SzConvert.toZeroStr(sCharge2[1]));
		sb.append(";");
		sb.append(SzConvert.toZeroStr(sCharge2[2]));
		sb.append(";");
		sb.append(tel);
		sb.append(";");		
		sb.append(mobile);
		sb.append(";");
		sb.append(cardid);
		sb.append(";");
		sb.append("End;");
       }

       dataReader.closeAll();
       out.println(sb.toString());


%>