<!-- #include file="../conn.asp" -->
<!-- #include file="../cls_main.asp" -->
<!-- #include file="../cls_ishion_showPage.asp" -->
<% MyDbPath = "../"
dim obj
set obj = New admin_products
	call obj.AspInit()
set obj = nothing

Class admin_products

	Private isEdit, y, ishion
	Private Sub Class_Initialize()
		Set ishion = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set ishion = Nothing
	End Sub
	Public Sub AspInit()
		Response.Write "<HTML>" & vbCrLf
		Response.Write "<HEAD>" & vbCrLf
		Response.Write "<TITLE>产品管理</TITLE>" & vbCrLf
		Response.Write "<META http-equiv=Content-Type content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<LINK href=""admin.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY leftmargin=""1"" topmargin=""1"">" & vbCrLf
		isEdit = False
			If ishion.adminName = "" Then
				ishion.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call ishion.SystemMsg
			Else
				Call Main
			End If
		Response.Write "</BODY>" & vbCrLf
		Response.Write "</HTML>" & vbCrLf
	
	End Sub

	Private Sub Main()
		Response.Write "<table width=""100%""  border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "<tr>" & vbCrLf
		Response.Write "  <td class=""tdbg2""><STRONG>管理快捷方式：</STRONG> <a href=""?action=add"">添加新产品</a> | <a href=""?action=index"">产品管理</a></td>" & vbCrLf
		Response.Write "</tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	
		Select Case Request("action")
		Case "saveadd"
			Call SaveAdd
		Case "modify"
			Call SaveModify
		Case "edit"
			isEdit = True
			Call myform
		Case "add"
			isEdit = False
			Call myform
		Case "del"
			Call del
		Case Else
			Call showList
		End Select
	End Sub
	Private Sub SaveAdd()
		Dim sContent, i, Rs, sql
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from ishion_Products where (ID is null)"
		Rs.open sql, Conn, 1, 3
		Rs.AddNew
		Rs("ProductName") = Trim(Request.Form("ProductName"))
		Rs("SmallImg") = Trim(Request.Form("SmallImg"))
		Rs("Description") = Request.Form("Description")
		Rs("ForPrice") = Trim(Request.Form("ForPrice"))
		Rs("FavPrice") = Trim(Request.Form("FavPrice"))
		Rs("Points") = CLng(Request.Form("Points"))
		Rs("Months") = CLng(Request.Form("Months"))
		Rs("VipType") = CLng(Request.Form("VipType"))
		Rs("DateAndTime") = Now()
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		ishion.strMsg = "<li>添加新产品操作成功！<li><a href=?action=add>继续添加新产品</a></li>"
		Call ishion.SystemMsg
	End Sub
	Private Sub SaveModify()
		Dim sContent, i, Rs, sql
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from ishion_Products where ID=" & CLng(Request.Form("ID"))
		Rs.open sql, Conn, 1, 3
		Rs("ProductName") = Trim(Request.Form("ProductName"))
		Rs("SmallImg") = Trim(Request.Form("SmallImg"))
		Rs("Description") = Request.Form("Description")
		Rs("ForPrice") = Trim(Request.Form("ForPrice"))
		Rs("FavPrice") = Trim(Request.Form("FavPrice"))
		Rs("Points") = CLng(Request.Form("Points"))
		Rs("Months") = CLng(Request.Form("Months"))
		Rs("VipType") = CLng(Request.Form("VipType"))
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		ishion.strMsg = "<li>修改产品信息操作成功！<li><a href=?action=add>继续添加新产品</a></li>"
		Call ishion.SystemMsg
	End Sub
	Private Sub del()
		Dim ID
		ID = Trim(Request("ID"))
		If ID <> "" Then
			ishion.Execute ("delete from ishion_Products where ID = " & ID)
		End If
		ishion.strMsg = "<li>删除产品操作成功！></li>"
		Call ishion.SystemMsg
	End Sub
	Private Sub showList()
		Dim sColumn, showPageRs, strSQL, Rs, i, currentPage
		If Trim(Request.QueryString("Page")) = "" Then
			currentPage = 1
		Else
			currentPage = CLng(Request.QueryString("Page"))
		End If
		sColumn = "ID,ProductName,Description,SmallImg,ForPrice,FavPrice,Points,Months,VipType,DateAndTime"
	
		Set showPageRs = New cls_ishion_showPage '创建对象
			If IsSqlDataBase = 1 Then
				showPageRs.DbType = "MSSQL"
			Else
				showPageRs.DbType = "AC"
			End If
			'数据库类型,AC为access,MSSQL为sqlserver2000,MSSQL_SP为存储过程版,MYSQL为mysql,PGSQL为PostgreSql
			showPageRs.RecType = 0
			'取记录总数方法(0执行count,1自写sql语句取,2固定值)
			showPageRs.RecSql = 0
			'如果RecType＝1则=取记录sql语句，如果是2=数值，等于0=""
			showPageRs.RecTerm = 2
			'取从记录条件是否有变化(0无变化,1有变化,2不设置cookies也就是及时统计，适用于搜索时候)
			showPageRs.CookieName = "admin_cms_special" '如果RecTerm＝2,cookiesname="",否则写cookiesname
			showPageRs.Order = 0              '排序(0顺序1降序),注意要和下面sql里面主键ID的排序对应
			showPageRs.PageSize = 30          '每页记录条数
			showPageRs.currentPage = currentPage
			showPageRs.sql = sColumn & "$ishion_Products$$ID$ID" '字段,表,条件(不需要where),排序(不需要需要ORDER BY),主键ID
		Dim iRecCount, sqlRs
		iRecCount = showPageRs.RecCount() '记录总数
		
		If iRecCount < 1 Then
			Response.Write "Sorry！没有找到任何记录。"
		Else
				'Response.Write "Test!"
				'Exit Sub
			Set sqlRs = showPageRs.ResultSet()  '返回ResultSet
			Rs = sqlRs.GetRows(-1)
			For i = 0 To UBound(Rs, 2)
			' sColumn = "ID,ProductName,Description,SmallImg,ForPrice,FavPrice,Points,Months,VipType,DateAndTime"
				Response.Write "<table width=""100%""  border=""0"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf
				Response.Write "  <tr>" & vbCrLf
				Response.Write "    <td width=""250"" rowspan=""5"" align=""center"" class=""tdbg3""><img src=""../" & Rs(3, i) & """ border=""0""></td>" & vbCrLf
				Response.Write "    <td class=""tdbg2"">名称：<b>" & Rs(1, i) & "</b></td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
				Response.Write "  <tr>" & vbCrLf
				Response.Write "    <td class=""tdbg3"">描述：" & Rs(2, i) & "</td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
				Response.Write "  <tr>" & vbCrLf
				Response.Write "    <td class=""tdbg2"">类型："
				If Rs(8, i) = 1 Then
					Response.Write "点数卡"
					Response.Write "　　面值：" & Rs(6, i) & "点"
				Else
					Response.Write "包月卡"
					Response.Write "　　面值：" & Rs(7, i) & "月"
				End If
				Response.Write "</td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
				Response.Write "  <tr>" & vbCrLf
				Response.Write "    <td class=""tdbg3"">原价：￥<font color=""red""><s>" & Rs(4, i) & "元</s></font>　　优惠价：￥<font color=""red"">" & Rs(5, i) & "元</font></td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
				Response.Write "  <tr>" & vbCrLf
				Response.Write "    <td class=""tdbg2"">管理操作：<a href=""?action=edit&id=" & Rs(0, i) & """>修改</a>　<a href=""?action=del_P&id=" & Rs(0, i) & """ onclick=""{if(confirm('执行此删除操作后该资源不能恢复，确定删除吗？')){return true;}return false;}"">删除</a></td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
				Response.Write "</table>" & vbCrLf
			Next
			Rs = Null
			Set sqlRs = Nothing
		End If
		If iRecCount > 0 Then
			Response.Write showPageRs.showPage("?Page={$pages}" & q)
		End If
	
		Set showPageRs = Nothing
		
	End Sub
	Sub myform()
		Response.Write "<script language=""Javascript"">" & vbCrLf
		Response.Write "<!--" & vbCrLf
		Response.Write "function SetSmallImg(){" & vbCrLf
		Response.Write "    var arr = showModalDialog(""../eWebEditor/Upload_Images_Dialog.asp?style=s_ishioncn"", """", ""dialogWidth:26em; dialogHeight:10em; status:0;help=no"");" & vbCrLf
		Response.Write "    if (arr ==null){" & vbCrLf
		Response.Write "        myform.SmallImg.value="""";" & vbCrLf
		Response.Write "        alert(""系统提示：当前没有上传图片，资源缩略图为空，用户可以重新上传图片！"");" & vbCrLf
		Response.Write "        //myform.SmallImg.focus();" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "    if (arr !=null){" & vbCrLf
		Response.Write "        myform.SmallImg.value=arr;" & vbCrLf
		Response.Write "    }" & vbCrLf
		Response.Write "}" & vbCrLf
		Response.Write "//-->" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<table width=""100%""  border=""0"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf
		Response.Write "<form name=""myform"" method=""post"" action=""admin_products.asp"">" & vbCrLf
		
		Response.Write "  <tr>" & vbCrLf
		Response.Write "    <td height=""19"" colspan=""2"" background=""../images/menubg.gif"" align=""center"">"
		If isEdit Then
			Set Rs = ishion.Execute("select * from ishion_Products where ID=" & CLng(Request.QueryString("ID")))
			Response.Write ("修改产品信息")
			Response.Write ("<input type=""Hidden"" name=""action"" value=""modify"">")
			Response.Write ("<input type=""Hidden"" name=""ID"" value=""" & Trim(Request.QueryString("ID")) & """>")
		Else
			Response.Write ("添加新产品")
			Response.Write ("<input type=""Hidden"" name=""action"" value=""saveadd"">")
		End If
		Response.Write "</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""right"">产品名称</td>" & vbCrLf
		Response.Write "    <td><input name=""ProductName"" type=""text"" id=""ProductName"" size=""40"" maxlength=""100"" value="""
		If isEdit Then Response.Write Rs("ProductName")
		Response.Write """></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td align=""right"">产品略缩图</td>" & vbCrLf
		Response.Write "    <td><input name=""SmallImg"" type=""text"" id=""SmallImg"" size=""40"" maxlength=""100"" value="""
		If isEdit Then Response.Write Rs("SmallImg")
		Response.Write """> <input type=""button"" value=""设置"" onclick=""SetSmallImg();""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""right"">描 述</td>" & vbCrLf
		Response.Write "    <td><textarea name=""Description"" cols=""40"" rows=""6"" id=""Description"">"
		If isEdit Then Response.Write Rs("Description")
		Response.Write "</textarea></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td align=""right"">原 价</td>" & vbCrLf
		Response.Write "    <td><input name=""ForPrice"" type=""text"" id=""ForPrice"" size=""10"" maxlength=""5"" value="""
		If isEdit Then Response.Write Rs("ForPrice")
		Response.Write """>" & vbCrLf
		Response.Write "    元</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""right"">优惠价</td>" & vbCrLf
		Response.Write "    <td><input name=""FavPrice"" type=""text"" id=""FavPrice"" size=""10"" maxlength=""5"" value="""
		If isEdit Then Response.Write Rs("FavPrice")
		Response.Write """>" & vbCrLf
		Response.Write "    元</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td align=""right"">积分点</td>" & vbCrLf
		Response.Write "    <td><input name=""Points"" type=""text"" id=""Points"" size=""10"" maxlength=""10"" value="""
		If isEdit Then Response.Write Rs("Points")
		Response.Write """>" & vbCrLf
		Response.Write "    点</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td align=""right"">月 份</td>" & vbCrLf
		Response.Write "    <td><input name=""Months"" type=""text"" id=""Months"" size=""10"" maxlength=""5"" value="""
		If isEdit Then Response.Write Rs("Months")
		Response.Write """>" & vbCrLf
		Response.Write "    月</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg3"">" & vbCrLf
		Response.Write "    <td align=""right"">产品类型</td>" & vbCrLf
		Response.Write "    <td><input name=""VipType"" type=""radio"" value=""1"" "
		If isEdit Then
			If Rs("VipType") = 1 Then Response.Write ("checked")
		Else
			Response.Write ("checked")
		End If
		Response.Write ">" & vbCrLf
		Response.Write "      点数卡" & vbCrLf
		Response.Write "      <input type=""radio"" name=""VipType"" value=""2"""
		If isEdit Then
			If Rs("VipType") = 2 Then Response.Write ("checked")
		End If
		Response.Write ">" & vbCrLf
		Response.Write "包月卡</td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr class=""tdbg2"">" & vbCrLf
		Response.Write "    <td>&nbsp;</td>" & vbCrLf
		Response.Write "    <td><input type=""submit"" name=""Submit"" value=""提交"">" & vbCrLf
		Response.Write "      <input type=""reset"" name=""Submit"" value=""重置""></td>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "</form>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	
		If isEdit Then Set Rs = Nothing
	End Sub
	
	Public Sub OnEndPage()
		Response.Write ishion.CopyRight
	End Sub ' OnEndPage

End Class %>

