<%@ Page CodeFileBaseClass="IlgharCMS.Lib.AdminPageBase" %>
<%@ Register TagPrefix="IlgharUC" TagName="Ime" Src="../../ime.dwt.ascx"%>
<%@ Register TagPrefix="IlgharUC" TagName="LanguageMenu" Src="../../language_menu.dwt.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->
<ilghar:Get ID="Data" Object="Data" InnerID="Request.QueryString['ID']" Validate="True" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑数据</title>
<ilghar:Comment><link rel="stylesheet" type="text/css" href="../../S01/CHS/css/common.css" /></ilghar:Comment>
<link rel="stylesheet" href="<%=CssPath%>common.css" />
<script type="text/javascript" src="<%=CommonPath%>ajax.js"></script>
<script type="text/javascript" src="<%=CommonPath%>uploader.js"></script>
<script type="text/javascript" src="<%=JsPath%>common.js"></script>
<ilgharUC:Ime Ime="true" Eot="true" runat="server" />
<script type="text/javascript">
var _action = null;
var _upload = false;
function XmlHttpCallBack(xmlHttp)
{
	if (xmlHttp == null || xmlHttp.status == 200)
	{
		if (_action == "Edit")
		{
			window.status = "编辑完成！";

			if (_upload)
			{
				_action = "Upload";
				window.status = "开始上传文件...";
				_uploader.Init({Status:"正在上传文件...",Params:"Lang=<%=ContentLang%>&Object=Data&Operation=" + _action + "&ID=<%=Request.QueryString["ID"]%>"});
				_uploader.Upload("File");
			}
			else
			{
				alert("编辑成功！");
				document.getElementById("Submit").disabled = false;
				window.status = "";
			}
		}
		else if (_action == "Upload")
		{
			if (arguments.length == 2)
				alert(arguments[1]);
			else
				alert("编辑成功！");
			document.getElementById("Submit").disabled = false;
			window.status = "";
		}
	}
	else
	{
		if (_action == "Edit")
			alert("编辑失败！请查看日志！");
		else if (_action == "Upload")
			alert("上传文件失败！请查看日志！");
		else
			alert("失败！请查看日志！");
	
		document.getElementById("Submit").disabled = false;
		window.status = "";
	}
}

function OnSubmit(form)
{
	if (form.Name.value == "")
	{
		alert("名称不能空！");
		form.Name.select();
		return false;
	}
	
	if (form.Number.value == "")
	{
		alert("编号不能空！");
		form.Number.select();
		return false;
	}
	
	if (!IsAllowedType(form.File.value, form.FileAllowedType.value))
	{
		alert("文件类型应为：" + form.FileAllowedType.value);
		form.File.select();
		return false;
	}
	
	_upload = _uploader.NeedUpload("File");	
	
	var data = "Name=" + encodeURIComponent(form.Name.value);
	data += "&Number=" + encodeURIComponent(form.Number.value);
	data += "&Description=" + encodeURIComponent(form.Description.value);
	data += "&Database=" + encodeURIComponent(form.Database.value);
	data += "&Language=" + encodeURIComponent(form.Language.value);
	data += "&CMSVersion=" + encodeURIComponent(form.CMSVersion.value);
	
	document.getElementById("Submit").disabled = true;
	_action = "Edit";
	_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=Data&Operation=Modify&ID=<%=Request.QueryString["ID"]%>", data, XmlHttpCallBack);
	return false;
}
</script>
</head>
<body>
<div class="WhiteHeader">
	<div class="Left"><img src="<%=ImagePath%>close_frame.gif" onclick="OpenCloseLeftFrame()" /></div>
	<div class="Title"><a href="list.aspx?Lang=<%=ContentLang%>">Data列表</a> → <span class="<%=ContentLang%>Font"><%=Data[Name]%></span></div>
	<div class="Right">
		<ilgharUC:LanguageMenu runat="server" />
		<img height="15" src="<%=ImagePath%>dropdown.gif" onMouseOver="this.src='<%=ImagePath%>dropdown_over.gif';ShowLanguageMenu(this);" onMouseOut="this.src='<%=ImagePath%>dropdown.gif'" />
		语言：<%=CurrentLanguage%>
	</div>
</div>
<div class="Block">
	<ul class="Title">
		<li class="Left"></li>
		<li class="Middle">编辑</li>
		<li class="Right"></li>
	</ul>
	<form method="post" onsubmit="return OnSubmit(this)">
		<table border="0" cellpadding="4" cellspacing="1">
			<tbody>
				<tr>
					<th width="120">名称：</th>
					<td><input type="text" name="Name" value="<%=Data[Name]%>" size="50" maxlength="50" class="Text <%=ContentLang%>Font" /></td>
				</tr>
				<tr>
					<th>编号：</th>
					<td><input type="text" name="Number" value="<%=Data[Number]%>" size="50" maxlength="100" class="Text" /></td>
				</tr>
				<tr>
					<th>描述：</th>
					<td>
						<textarea name="Description" cols="70" rows="6" wrap="off" class="Text <%=ContentLang%>Font"><%=Data[Description]%></textarea>
					</td>
				</tr>
				<tr>
					<th>数据库：</th>
					<td>
						<select name="Database">
							<option value="Access">Access</option>
							<option value="SqlServer">SqlServer</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>语言：</th>
					<td><input type="text" name="Language" value="<%=Data[Language]%>" maxlength="50" class="Text <%=ContentLang%>Font" /></td>
				</tr>
				<tr>
					<th>CMS版本：</th>
					<td><input type="text" name="CMSVersion" value="<%=Data[CMSVersion]%>" size="10" maxlength="10" class="Text" /></td>
				</tr>
				<tr>
					<th>文件：</th>
					<td>
						<input id="FileTextbox" type="text" name="File" value="<%=Data[File]%>" size="60" disabled="disabled" class="Text" />
						<input id="FileBrowse" type="button" value="浏览..." />
						<input type="hidden" name="FileAllowedType" value="zip" />
					</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="2"><input type="submit" id="Submit" class="Button" value="编辑" /></td>
				</tr>
			</tfoot>
		</table>
	</form>
	<div class="Footer"></div>
</div>
<script type="text/javascript">
CheckAndSelect("<%=Data[Database]%>", document.forms[0].Database);

_uploader.Init({WebPath:"<%=WebPath%>",OnComplete:XmlHttpCallBack});
_uploader.Add("File", "FileTextbox", "FileBrowse");

HandleFake404();
</script>
</body>
</html>