<!--#include file="../../Conn.asp" -->
<!--#include file="../../Comm/Site_Class.asp" -->
<%
PagePath = "../../"

Set Qsite = New Site_Class

Qsite.SiteConfig_Master()
%>
<!--#include file="../Check_Login.asp" -->
<%
Qsite.Check_AdminFlag(arrAdminFlag(1 , 1))

Dim CompanyNameMemberEndDate
Dim selBeginYear,selBeginMonth,selBeginDay
Dim selEndYear,selEndMonth,selEndDay
Dim ThisYear,CompanyName

Set Rs = server.CreateObject("ADODB.recordset")

If Request.Form <> "" Then
	ComId = Qsite.chgStr(Trim(Request.Form("ComId")))
	MemberType = Qsite.chgStr(Trim(Request.Form("MemberType")))
	selBeginYear = Qsite.chgStr(Trim(Request.Form("BeginYear")))
	selBeginMonth = Qsite.chgStr(Trim(Request.Form("BeginMonth")))
	selBeginDay = Qsite.chgStr(Trim(Request.Form("BeginDay")))
	selEndYear = Qsite.chgStr(Trim(Request.Form("EndYear")))
	selEndMonth = Qsite.chgStr(Trim(Request.Form("EndMonth")))
	selEndDay = Qsite.chgStr(Trim(Request.Form("EndDay")))
	
	If ComId = "" Or IsNull(ComId) Or Not IsNumeric(ComId) Then ComId = 0
	
	If MemberType = "" Or IsNull(MemberType) Or Not IsNumeric(MemberType) Then MemberType = 0
	
	If selEndYear < selBeginYear Then
		Qsite.ShowMsg "结束时间不能小于开始时间" , ""
	End If
	If selEndYear = selBeginYear And selEndMonth < selBeginMonth Then
		Qsite.ShowMsg "结束时间不能小于开始时间" , ""
	End If
	If selEndYear = selBeginYear And selEndMonth = selBeginMonth And selEndDay < selBeginDay Then
		Qsite.ShowMsg "结束时间不能小于开始时间" , ""
	End If
	
	MemberBeginDate = Qsite.FormatDate(selBeginYear & "-" & selBeginMonth & "-" & selBeginDay)
	
	MemberEndDate = Qsite.FormatDate(selEndYear & "-" & selEndMonth & "-" & selEndDay)
	
	If Not IsDate(MemberBeginDate) Then
		Qsite.ShowMsg "开始时间格式不对" , ""
	End If
	
	If Not IsDate(MemberEndDate) Then
		Qsite.ShowMsg "结束时间格式不对" , ""
	End If
	
	Conn.Execute("update CompanyTbl set MemberType = "& MemberType &" , MemberBeginDate = '"& MemberBeginDate &"' , MemberEndDate = '"& MemberEndDate &"' where ComId = "& ComId)
	
	Response.Write("<script language=""javascript"">alert(""会员设置成功"");opener.location.reload();window.close();</script>")
	Response.End()
	
End If

ComId = Qsite.chgStr(Trim(Request.QueryString("ComId")))

If ComId = "" Or IsNull(ComId) Or Not IsNumeric(ComId) Then ComId = 0

If ComId = 0 Then
	Response.Write("非法参数1")
	Response.End()
End If

Rs.Open "select * from CompanyTbl where ComId = "& ComId , Conn , 1 , 1
If Rs.Eof Then
	Response.Write("非法参数2")
	Response.End()
Else
	CompanyName = Rs("CompanyName")
	MemberType = Rs("MemberType")
	MemberBeginDate = Rs("MemberBeginDate")
	MemberEndDate = Rs("MemberEndDate")
End If
Rs.Close

If IsDate(MemberBeginDate) Then
	SelBeginYear = Year(MemberBeginDate)
	selBeginMonth = Month(MemberBeginDate)
	selBeginDay = Day(MemberBeginDate)
End If

If IsDate(MemberEndDate) Then
	SelEndYear = Year(MemberEndDate)
	selEndMonth = Month(MemberEndDate)
	selEndDay = Day(MemberEndDate)
End If

ThisYear = Year(Date())
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>企业会员设定</title>
<link href="../skins/css/main.css" rel="stylesheet" type="text/css">
<script language="javascript">
function CheckForm()
{
	if(MemForm.EndYear.value < MemForm.BeginYear.value)
	{
		alert("结束时间不能小于开始时间");
		return false;
	}
	if(MemForm.EndYear.value == MemForm.BeginYear.value && MemForm.EndMonth.value < MemForm.BeginMonth.value)
	{
		alert("结束时间不能小于开始时间");
		return false;
	}
	if(MemForm.EndYear.value == MemForm.BeginYear.value && MemForm.EndMonth.value < MemForm.BeginMonth.value && MemForm.EndDay.value < MemForm.BeginDay.value)
	{
		alert("结束时间不能小于开始时间");
		return false;
	}
	return true;
}

function SetMember(ComId)
{
	window.open('Company_SetMember.asp?ComId=' + ComId , 'SetMember' , 'width=300,height=200,top=200,left=300');
}
</script>
</head>

<body>
<form name="MemForm" method="post" action="Company_SetMember.asp" style="margin:0" onSubmit="return CheckForm();">
<table width="100%" border="0" cellspacing="1" cellpadding="5">
	<tr>
		<td height="25" colspan="2" class="td_title"><%=CompanyName%> - 会员设定
			<input name="ComId" type="hidden" id="ComId" value="<%=ComId%>"></td>
	</tr>
	<tr>
		<td width="25%" height="23" class="td_content">会员类型：</td>
		<td width="75%" class="td_content"><select name="MemberType" class="input_1" id="MemberType">
		<%
		Rs.Open "select * from MemberConfigTbl order by MemberId asc" , Conn , 1 , 1
		Do While Not Rs.Eof
		%>
			<option value="<%=Rs("MemberId")%>" <%If Cstr(Rs("MemberId")) = Cstr(MemberType) Then Response.Write("selected")%>><%=Rs("MemberName")%></option>
		<%
		Rs.MoveNext
		Loop
		Rs.Close
		%>
		</select>
		</td>
	</tr>
	<tr>
		<td height="23" class="td_content">开始时间：</td>
		<td class="td_content"><select name="BeginYear" class="input_1" id="BeginYear">
		<%
			For i = ThisYear To ThisYear + 15
				Response.Write("<option value="""& i &""" ")
				If Cint(i) = Cint(selBeginYear) Then Response.Write(" selected")
				Response.Write(">"& i &"</option>")
			Next
		%>
		</select>
			年
			<select name="BeginMonth" class="input_1" id="BeginMonth">
			<%
				For i = 1 To 12
					Response.Write("<option value="""& i &""" ")
					If Cint(i) = Cint(selBeginMonth) Then Response.Write(" selected")
					Response.Write(">"& i &"</option>")
				Next
			%>
			</select>
			月
			<select name="BeginDay" class="input_1" id="BeginDay">
			<%
				For i = 1 To 31
					Response.Write("<option value="""& i &""" ")
					If Cint(i) = Cint(selBeginDay) Then Response.Write(" selected")
					Response.Write(">"& i &"</option>")
				Next
			%>
			</select>
			日
			</td>
	</tr>
	<tr>
		<td height="23" class="td_content">结束时间：</td>
		<td class="td_content"><select name="EndYear" class="input_1" id="EndYear">
		<%
			For i = ThisYear To ThisYear + 15
				Response.Write("<option value="""& i &""" ")
				If Cint(i) = Cint(selEndYear) Then Response.Write(" selected")
				Response.Write(">"& i &"</option>")
			Next
		%>
		</select>
			年
			<select name="EndMonth" class="input_1" id="EndMonth">
			<%
				For i = 1 To 12
					Response.Write("<option value="""& i &""" ")
					If Cint(i) = Cint(selEndMonth) Then Response.Write(" selected")
					Response.Write(">"& i &"</option>")
				Next
			%>
			</select>
			月
			<select name="EndDay" class="input_1" id="EndDay">
			<%
				For i = 1 To 31
					Response.Write("<option value="""& i &""" ")
					If Cint(i) = Cint(selEndDay) Then Response.Write(" selected")
					Response.Write(">"& i &"</option>")
				Next
			%>
			</select>
			日
			</td>
	</tr>
	<tr>
		<td height="23" class="td_content">&nbsp;</td>
		<td class="td_content"><input name="Submit" type="submit" class="input_1" value="确定"></td>
	</tr>
</table>
</form>
</body>
</html>
