<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!--#include file="cook_conn.asp"--><head>
	<title>
		<%=DEF_SiteNameString%>——我的冰箱
	</title>
	<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
	<link rel="stylesheet" type="text/css" href="<%=DEF_BBS_homeurl%>/inc/style.css">
</head>
<script language="JavaScript">
function checkform()
{
if(document.sendit.username.value == ""){
 alert("请输入接受人名称！");
 return false ;
 }
}
</script>
<%'tinder
DEF_BBS_HomeUrl = "../../"

siteHead("   厨房")


	'BBS_SiteHead DEF_SiteNameString&" "&DEF_BBS_Name,GBL_board_ID,headvar 
dim membername,founderr,SQL,Rs,tinder_errmsg
'dim iif
membername=GBL_CHK_User'tinder
dim fridgers
if membername=""  then
	founderr=true
end if
if founderr then
	tinder_errmsg=tinder_errmsg+"<br>"+"<li>您没有进入雪石厨房的权限，请先登陆或者同管理员联系。"
	call tinder_error()
end if
OpenDatabase
select case request("action")
   case "listdish"
	call listdish()
   case "sendit"
	call sendit()
   case else
	call fridgemain()
end select
closeDatabase
cookconn.close
Set cookconn = Nothing
'call footer()

'sub部分
sub fridgemain()
dim perpage,pageno,iii
perpage=6'每页10个
pageno=1'页数
iii=1
	       if request("action")="sending" then'送
	          set rs=server.createobject("adodb.recordset")
	          sql="select * from [leadbbs_user] where username='"&request("username")&"'"
	          rs.open sql,con,1,1
	          if rs.recordcount<1 then
	             %><script language="vbscript">
			msgbox"无此用户“<%=request("username")%>”，请检查！",0,"雪石"
			history.back
			</script><%
			rs.close
			set rs=nothing
			exit sub
	          end if
	          rs.close
		  set rs=nothing
		  if len(request("Content"))>50 then
		     %><script language="vbscript">
			msgbox"赠言超过50个了，请减短！",0,"雪石"
			history.back
			</script><%
			exit sub
		  end if
		  cookconn.execute "update fridge set username='"&request("username")&"',type=1,senduser='"&membername&"',sendword='"&request("Content")&"',adddate='"&now&"' where username='"&membername&"' and id="&request("dishid")
		  
		  dim msgsender,msgtitle,msgbody
		  msgsender=membername
		  msgtitle=DEF_BBS_Name&"送菜服务。"
		  msgbody="“"&request("username")&"”你好，“"&membername&"”送了一道亲手做的菜给你，"&chr(10)&"已经放在你的冰箱！"
		  	sql="insert into LeadBBS_InfoBox(FromUser,ToUser,title,content,sendtime,ReadFlag) values('"&request("username")&"','"&msgsender&"','"&msgtitle&"','"&msgbody&"',Now(),0)"
			con.Execute sql
		 'Con.Execute("Update LeadBBS_User Set MessageFlag=1 where username=" & msgsender)
	  	  %><script language="vbscript">
		  msgbox"菜已经送出！",0,"雪石"
		  </script><%
		  
	       end if
	       if request("action")="dele" then'扔了
	          cookconn.execute "delete from fridge where id="&request("dishid")&" and username='"&membername&"'"
	          %><script language="vbscript">
		  msgbox"小菜已经扔了！",0,"雪石"</script><%
	       end if
	       
	       if request("action")="eat" then'吃了
	          set fridgers=server.createobject("adodb.recordset")
		  sql="select addep,addcp from fridge where id="&request("dishid")&" and username='"&membername&"'"
		  fridgers.open sql,cookconn,1,1
	          if not fridgers.eof and not fridgers.bof then 
	       	     con.execute "update [leadbbs_user] set onlinetime=onlinetime+"&fridgers("addep")*60&",charmpoint=charmpoint+"&fridgers("addcp")&" where username='"&membername&"'"
	       	  end if
	       	  %><script language="vbscript">
		  msgbox"小菜已经吃了，增加经验<%=fridgers("addep")%>点，魅力<%=fridgers("addcp")%>点！",0,"雪石"
		  </script><%
		  fridgers.close
		  set fridgers=nothing
		  cookconn.execute "delete from fridge where id="&request("dishid")&" and username='"&membername&"'"
	       end if
	       
	       if request("action")="sell" then'卖了
	          set fridgers=server.createobject("adodb.recordset")
		  sql="select addwealth from fridge where id="&request("dishid")&" and username='"&membername&"'"
		  fridgers.open sql,cookconn,1,1
		  if not fridgers.eof and not fridgers.bof then 
	       	     con.execute "update [leadbbs_user] set points=points+"&fridgers("addwealth")&" where username='"&membername&"'"
	       	  end if
	  	  %><script language="vbscript">
		  msgbox"小菜已经卖了，增加财产<%=fridgers("addwealth")%>元！",0,"雪石"
		  </script><%
		  fridgers.close
		  set fridgers=nothing
		  cookconn.execute "delete from fridge where id="&request("dishid")&" and username='"&membername&"'"
	       end if
	       
if not isnull(request("page")) and clng(request("page"))>=1 then
	pageno=request("page")
end if
if founderr then
	call dvbbs_error()
	exit sub
end if
set fridgers=server.createobject("adodb.recordset")
sql="Select * from fridge where username='"&membername&"' order by adddate desc"
fridgers.open sql,cookconn,1,1
%>


<table align=center cellSpacing="1" cellPadding="0" class=TBone  width=100%>
  <tr class=tbhead2> <th height="25" align="center" colspan="7">保鲜室</th></tr>
   <tr class=tbbg1>
      <td height="20" align="center"  valign="top" Class=TableTitle2><b>小菜名称</b></td>
      <td height="20" align="center" valign="top" Class=TableTitle2><b>照片</b></td>
      <td height="20" align="center" valign="top" colspan="3" Class=TableTitle2><b>动作</b></td>
      <td height="20" align="center" valign="top" Class=TableTitle2><b>赠送人</b></td>
      <td height="20" align="center" valign="top" Class=TableTitle2><b>处理</b></td>
   </tr>
<%
if fridgers.recordcount>=1 then
do while not fridgers.eof
   if iii>pageno*perpage then
	exit do
   end if
   if iii>pageno*perpage-perpage and iii<=pageno*perpage then%>
   <tr class=tbbg1>
      <td height="20" align="center"  valign="center" Class=tableBody2>
      <a href="cook_fridge.asp?action=listdish&dishid=<%=fridgers("id")%>&page=<%=pageno%>"><%=fridgers("dish")%></a></td>
      <td height="20" align="center" valign="center" Class=tableBody1>
      <%if trim(fridgers("dishpic"))="" or isnull(fridgers("dishpic")) then%>
	<img src="Kitchen/img/d000000.gif" height="32" width="32"><%else %>
	<img src="<%=fridgers("dishpic")%>" height="32" width="32"><%end if%></td>
      <td height="20" align="center" valign="center" Class=tableBody2><a href="cook_fridge.asp?action=eat&dishid=<%=fridgers("id")%>">品尝</a></td>
      <td height="20" align="center" valign="center" Class=tableBody1>
      <%if fridgers("type")=1 then%>&nbsp;&nbsp;<%else %><a href="cook_fridge.asp?action=sendit&dishid=<%=fridgers("id")%>&page=<%=pageno%>">送人</a><%end if%></td>
      <td height="20" align="center" valign="center" Class=tableBody2><a href="cook_fridge.asp?action=sell&dishid=<%=fridgers("id")%>">卖了</a></td>
      <td height="20" align="center" valign="center" Class=tableBody1>
      <%if fridgers("type")=1 and fridgers("senduser")<>"" then%><%=fridgers("senduser")%><%else %>&nbsp;&nbsp;<%end if%></td>
      <td height="20" align="center" valign="center" Class=tableBody2><a href="cook_fridge.asp?action=dele&dishid=<%=fridgers("id")%>">扔了</a></td>
   </tr>
<%
   end if
   iii=iii+1
   fridgers.movenext
loop
%><tr class=tbbg1><td height="25" align="right" colspan="7" Class=tableBody1>
<%if pageno>1 then%><a href="cook_fridge.asp?page=1"><font face=webdings>9</font></a><%else%><font face=webdings color=red>9</font><%end if%>&nbsp;<%
if pageno>1 then%><a href="cook_fridge.asp?page=<%=pageno-1%>"><font face=webdings>7</font></a><%else%><font face=webdings color=red>7</font><%end if%>&nbsp;<%
if clng(pageno) < clng(abs(int(0-fridgers.recordcount/perpage))) then
%><a href="cook_fridge.asp?page=<%=pageno+1%>"><font face=webdings>8</font></a><%else%><font face=webdings color=red>8</font><%end if%>&nbsp;<%
if clng(pageno) < clng(abs(int(0-fridgers.recordcount/perpage))) then
%><a href="cook_fridge.asp?page=<%=abs(int(0-fridgers.recordcount/perpage))%>"><font face=webdings>:</font></a><%else%><font face=webdings color=red>:</font><%end if%>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page&nbsp;<%=pageno%>&nbsp;of&nbsp;<%=abs(int(0-fridgers.recordcount/perpage))%>&nbsp;</td></tr>
<%end if%></table><%
fridgers.close
set fridgers=nothing
end sub

sub listdish()

set fridgers=server.createobject("adodb.recordset")
sql="Select * from fridge where id="&request("dishid")
fridgers.open sql,cookconn,1,1
%>
<table align=center cellSpacing="1" cellPadding="0" class=TBone height="100" width=100%>
   <tr class=tbhead2><th height="25" align="center" colspan="2">小菜资料</th></td><%
if not fridgers.eof and not fridgers.bof then
   %><tr class=tbbg1>
   <td height="20" width="88" align="center" valign="center" Class=tableBody1>
      <%if trim(fridgers("dishpic"))="" or isnull(fridgers("dishpic")) then%>
	<img src="Kitchen/img/d000000.gif" height="86" width="86"><%else %>
	<img src="<%=fridgers("dishpic")%>" height="86" width="86"><%end if%><br>
   	<%=fridgers("dish")%></td>
   
   <td height="20" align="left" valign="center" Class=tableBody2>
   	<%
   	if fridgers("type")=1 then
   	   dim sendword
   	   if fridgers("sendword")<>"" and not isnull(fridgers("sendword")) then
   	      sendword=Replace(fridgers("sendword"), CHR(10), "<BR>")
   	   end if
   	   %>赠言：<br><br>&nbsp;&nbsp;
   	   <%if fridgers("sendword")="" or isnull(fridgers("sendword")) then%>这是我的一点心意，希望你开开心心每一天。:)
   	   <%else%><%=sendword%><%end if%><br><br>
   	   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   	   <a target="_blank" href="dispuser.asp?name=<%=fridgers("senduser")%>">
   	   <%=fridgers("senduser")%></a><br><%
   	else
   	   %>介绍：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;
   	   <%
   	   if fridgers("dish")="奇怪的小菜" then
   	      %>该道菜奇奇怪怪的，不知道可不可吃，吃了也许会有损健康，不如扔了。<br><br><%
   	   else
   	      %>这道菜果真色香味具佳，让人不禁眼馋嘴馋，吃了一定有益健康。<br><br><%
   	   end if
   	end if
   	response.write fridgers("adddate")
   	%>
   </td>
   </tr>
   <tr class=tbbg1>
   <td height="20" align="center" valign="center" colspan="2" Class=tableBody2>
   <a href="cook_fridge.asp?page=<%=request("page")%>"><font color=purple>返回</font></a>
   </td>
   </tr>
   <%
end if
%></table><%

fridgers.close
set fridgers=nothing
end sub

sub sendit()
set fridgers=server.createobject("adodb.recordset")
sql="Select * from fridge where id="&request("dishid")
fridgers.open sql,cookconn,1,1
%>

<form name="sendit" method="POST" action=cook_fridge.asp?dishid=<%=fridgers("id")%>&action=sending onSubmit="return checkform()">
<table align=center cellSpacing="1" cellPadding="0" class=TBone height="100" width=100%>
   <tr class=tbhead2><th height="25" align="center" colspan="2">赠送选项</th></td><%
   if not fridgers.eof and not fridgers.bof then
   %><tr class=tbbg1>
   <td height="20" width="88" align="center" valign="center" Class=tableBody1>
      <%if trim(fridgers("dishpic"))="" or isnull(fridgers("dishpic")) then%>
	<img src="Kitchen/img/d000000.gif" height="86" width="86"><%else %>
	<img src="<%=fridgers("dishpic")%>" height="86" width="86"><%end if%><br>
   	<%=fridgers("dish")%></td>
   
   <td height="20" align="left" valign="center" Class=tableBody2>
   	送给：<input type="text" name="username" size="15" value=""><br>
   	赠言：<br>
   	<textarea cols=34 name=Content rows=6 title="填入您想留给对方赠言"></textarea><br>
   	<input type="submit" name="Submit" value="确定">
   </td>
   </tr>
   <tr class=tbbg1>
   <td height="20" align="center" valign="center" colspan="2" Class=tableBody2>
   <a href="cook_fridge.asp?page=<%=request("page")%>"><font color=purple>返回</font></a>
   </td>
   </tr><%
   'if strLength(body)>Clng(Board_Setting(16)) then
'	ErrMsg=ErrMsg+"<Br>"+"<li>发言内容不得大于" & CSTR(Board_Setting(16)) & "bytes"
'	FoundErr=true
   'end if
   end if
%></form></table><%
fridgers.close
set fridgers=nothing
end sub
%>