📄 knowmate_s.jsp
字号:
<!-------------------------------------------------------------
* @ name: knowmate_s.jsp
* @ Author : ranxu
* @ date :2008-06-05
-------------------------------------------------------------->
<%@ page import='java.io.*,java.text.*,java.util.Date,java.util.Vector, java.sql.*, com.entaz.lib.db.*, com.entaz.relay.net.*' contentType='text/html;charset=euc-kr'%>
<%@ include file="../imgpath.jsp"%>
<%@ include file="../common_func.jsp"%>
<%!
/*------------------------------------------------------------------------------------------------------
+ method:getAnswer()
action:Answer 1(db)--"O"(jsp) 0(db)--"X"(jsp)
author:ranxu 2008-06-05
-------------------------------------------------------------------------------------------------------*/
int ANSWER_O = 1;
int ANSWER_X = 0;
public String getAnswer(int key)
{
String ret = "";
if(key==ANSWER_O){
ret = "O";
}else if(key==ANSWER_X){
ret = "X";
}
return ret;
}
%>
<%
/*------------------------------------------------------------------------------------------------------
parameter from last page:soulmate_main.jap
-------------------------------------------------------------------------------------------------------*/
String nickname = request.getParameter("nickname");
String mphone = request.getParameter("mphone");
String gphone = request.getParameter("gphone");
String status = request.getParameter("status");
String guestAnswer = request.getParameter("ox");
/*------------------------------------------------------------------------------------------------------
+ DB
-------------------------------------------------------------------------------------------------------*/
PreparedStatement pstmt = null;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
int ret = -1;
/*------------------------------------------------------------------------------------------------------
+ parameter of current page
-------------------------------------------------------------------------------------------------------*/
int quiz_idx=0;
String title = "";
int hostAnswer = 0;
int nregdate = 0;
String regdate = "";
double allCount = 0.0;
double answeredCount = 0.0;
double answeredRightCount = 0.0;
int unansweredCount = 0;
List unansweredIdxs = null;
List unansweredTitles = null;
List hostAnswers = null;
/*-------------------------------------------------------------------------------------------------------
get title and answer of the blog's host
-------------------------------------------------------------------------------------------------------*/
con = DBConnector.getConnection(db_name);
if( con == null )
{
title="";
return;
}
sql = " select top 1 a.* from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone=?"+
" and a.quiz_idx not in"+
" (select distinct a.quiz_idx from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone =?"+
" )order by a.idx desc";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(gphone));
pstmt.setLong(3,Long.parseLong(gphone));
pstmt.setLong(4,Long.parseLong(mphone));
rs=pstmt.executeQuery();
if(rs.next()){
quiz_idx = rs.getInt("quiz_idx");
title = rs.getString("title");
hostAnswer = rs.getInt("answer");
}
rs.close();
pstmt.close();
/*-------------------------------------------------------------------------------------------------------
insert guest's answer
-------------------------------------------------------------------------------------------------------*/
if(status.equals("insertOne")){
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql="select * from gt_lucky_quiz_mylog where quiz_idx =? and phonenum=? and guest_phone=?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1,quiz_idx);
pstmt.setLong(2,Long.parseLong(gphone));
pstmt.setLong(3,Long.parseLong(mphone));
rs = pstmt.executeQuery();
if(rs.next()){
}else{
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql="insert into gt_lucky_quiz_mylog (quiz_idx,title,answer,phonenum,guest_phone)values (?,?,?,?,?)";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1,quiz_idx);
pstmt.setString(2,title);
pstmt.setString(3,guestAnswer);
pstmt.setString(4,gphone);
pstmt.setString(5,mphone);
ret = pstmt.executeUpdate();
if(ret==-1){
return;
}
pstmt.close();
}
rs.close();
pstmt.close();
}
/*-------------------------------------------------------------------------------------------------------
get the count of all title which the host have answered
-------------------------------------------------------------------------------------------------------*/
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql = " select count(1) allcount from gt_lucky_quiz_mylog a,gt_lucky_quiz b "+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone=? ";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(gphone));
rs=pstmt.executeQuery();
if(rs.next()){
allCount = rs.getDouble("allcount");
}
rs.close();
pstmt.close();
/*-------------------------------------------------------------------------------------------------------
get the count of guest answered title
-------------------------------------------------------------------------------------------------------*/
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql = " select count(distinct a.idx) answeredcount from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone =?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(mphone));
rs=pstmt.executeQuery();
if(rs.next()){
answeredCount = rs.getDouble("answeredcount");
}
rs.close();
pstmt.close();
/*-------------------------------------------------------------------------------------------------------
update attention point when the guest answer the question at the first time
-------------------------------------------------------------------------------------------------------*/
System.out.println(answeredCount+"====answeredCount===1.0====");
if(answeredCount==1.0){
sql = "update gt_lucky_attention_point set attention_point=attention_point+1 where phonenum=? and guest_phone=?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(mphone));
ret = pstmt.executeUpdate();
pstmt.close();
}
/*-------------------------------------------------------------------------------------------------------
get the count of guest answered right title
-------------------------------------------------------------------------------------------------------*/
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql = " select count(a.idx) answeredrightcount from gt_lucky_quiz_mylog a,gt_lucky_quiz b,gt_lucky_quiz_mylog c"+
" where a.quiz_idx = b.idx and b.flag=1 and a.quiz_idx=c.quiz_idx and a.answer = c.answer"+
" and a.phonenum =? and a.guest_phone =? "+
" and c.phonenum =? and c.guest_phone =? ";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(gphone));
pstmt.setLong(3,Long.parseLong(gphone));
pstmt.setLong(4,Long.parseLong(mphone));
rs=pstmt.executeQuery();
if(rs.next()){
answeredRightCount = rs.getDouble("answeredrightcount");
}
rs.close();
pstmt.close();
/*-------------------------------------------------------------------------------------------------------
get the count of guest unanswered title
-------------------------------------------------------------------------------------------------------*/
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql = " select count(a.idx) answeredcount from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone=?"+
" and a.quiz_idx not in"+
" (select distinct a.quiz_idx from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone =? )";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(gphone));
pstmt.setLong(3,Long.parseLong(gphone));
pstmt.setLong(4,Long.parseLong(mphone));
rs=pstmt.executeQuery();
if(rs.next()){
unansweredCount = rs.getInt("answeredcount");
}
rs.close();
pstmt.close();
/*-------------------------------------------------------------------------------------------------------
get the unanswered title
-------------------------------------------------------------------------------------------------------*/
unansweredTitles = new ArrayList();
hostAnswers = new ArrayList();
unansweredIdxs = new ArrayList();
con = DBConnector.getConnection(db_name);
if( con == null )
{
return;
}
sql = " select top 5 a.* from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone=? "+
" and a.quiz_idx not in "+
" (select distinct a.quiz_idx from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
" where a.quiz_idx = b.idx and b.flag=1 "+
" and a.phonenum =? and a.guest_phone =? "+
" )order by a.idx desc";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(gphone));
pstmt.setLong(3,Long.parseLong(gphone));
pstmt.setLong(4,Long.parseLong(mphone));
rs=pstmt.executeQuery();
while(rs.next()){
unansweredIdxs.add(rs.getString("quiz_idx"));
unansweredTitles.add(rs.getString("title"));
hostAnswers.add(rs.getString("answer"));
}
rs.close();
pstmt.close();
for(int i=0;i<unansweredIdxs.size();i++){
System.out.println(unansweredTitles.get(i)+"===unansweredTitles====s");
System.out.println(unansweredIdxs.get(i)+"===unansweredIdxs====s");}
%>
<html>
<head>
<link href="http://entaz.mugeta.com/client/mugeta_v2_test/web/user/mobile.css" rel="stylesheet" type="text/css">
<title>权> 酒捞叼咯几磊丛俊 措秦 舅扁</title>
</head>
<body>
<!--剧侥
<tr>
<td>
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
-->
<form name="form1" action="knowmate_k.jsp" method="post">
<input type="hidden" name="mphone" value="<%=mphone%>">
<input type="hidden" name="gphone" value="<%=gphone%>">
<input type="hidden" name="nickname" value="<%=nickname%>">
<input type="hidden" name="status" value="insertMulti">
<table width="240" border="0" cellspacing="0" cellpadding="0">
<!--鸥捞撇 矫累-->
<tr>
<td>
<table width="240" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" height="2" bgcolor="#c789ff"></td>
</tr>
<tr>
<td width="10" height="15" bgcolor="#9819e9"></td>
<td height="15" bgcolor="#9819e9"><font color="#ffffff"><%=nickname %>丛俊 措秦 舅扁</font></td>
</tr>
<tr>
<td colspan="2" height="1" bgcolor="#9819e9"></td>
</tr>
</table>
</td>
</tr>
<!--鸥捞撇 场-->
<!--咯归 矫累-->
<tr>
<td height="8"></td>
</tr>
<!--咯归 场-->
<!--xx丛 荤角 捞犯促 冠胶 矫累-->
<tr>
<td>
<table width="240" bgcolor="#ecaaff" border="0" cellspacing="0" cellpadding="0">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -