<%@ 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:List ID="Unit" Object="Unit" />
<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="<%=JsPath%>common.js"></script>
<ilgharUC:Ime Ime="true" Eot="true" runat="server" />
<script language="c#" runat="server">
protected bool Exists(string guid)
{
	DataRow[] rows = Unit.Select(Alias.Unit.ID + "='" + guid + "'");
	if (rows.Length > 0)
		return true;
	else
		return false;
}
</script>
<script type="text/javascript">
function XmlHttpCallBack(xmlHttp)
{
	if (xmlHttp.status == 200)
		alert("添加成功！");
	else
		alert("添加失败！请查看日志！");

	document.getElementById("Submit").disabled = false;
}

function OnSubmit(form)
{
	if (form.Name.value == "")
	{
		alert("名称不能空！");
		form.Name.select();
		return false;
	}
	
	var data = "Name=" + encodeURIComponent(form.Name.value);
	if (form.Predefine.value != "")
		data += "&ID=" + form.Predefine.value;
	
	document.getElementById("Submit").disabled = true;
	_ajax.Post("<%=WebPath%>ilghar.aspx?Lang=<%=ContentLang%>&Object=Unit&Operation=Add", data, XmlHttpCallBack);
	return false;
}

function Predefine_OnChange()
{
	var form = document.forms[0];
	if (form.Predefine.selectedIndex == 0)
		form.Name.value = "";
	else
		form.Name.value = form.Predefine.options[form.Predefine.selectedIndex].text;
}
</script>
</head>
<body>
<div class="WhiteHeader">
	<div class="Left"><img src="<%=ImagePath%>close_frame.gif" onclick="OpenCloseLeftFrame()" /></div>
	<div class="Title">添加计量单位</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="TabMenu">
		<li class="Left"></li>
		<li class="Middle"><a href="list.aspx?Lang=<%=ContentLang%>">计量单位列表</a></li>
		<li class="Right"></li>
		<li class="Left Selected"></li>
		<li class="Middle Selected">添加计量单位</li>
		<li class="Right Selected"></li>
	</ul>
	<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>预设单位：</th>
					<td>
						<select name="Predefine" onchange="Predefine_OnChange()">
							<option value="">未指定</option>
							<%If !Exists("{14A1F368-FD5A-4DC8-975B-4B53054A8B57}")%>
								<option value="{14A1F368-FD5A-4DC8-975B-4B53054A8B57}">年</option>
							<%EndIf%>
							<%If !Exists("{DF6F21BA-225A-4ED7-B09B-DF4E098F75AB}")%>
								<option value="{DF6F21BA-225A-4ED7-B09B-DF4E098F75AB}">半年</option>
							<%EndIf%>
							<%If !Exists("{4D544026-8DCD-4973-8416-71B0C0CF12D5}")%>
								<option value="{4D544026-8DCD-4973-8416-71B0C0CF12D5}">季</option>
							<%EndIf%>
							<%If !Exists("{59A2E817-95D2-499C-A149-49F91376BD21}")%>
								<option value="{59A2E817-95D2-499C-A149-49F91376BD21}">月</option>
							<%EndIf%>
							<%If !Exists("{39F612F1-482B-42E2-8914-33ACCEAE60DE}")%>
								<option value="{39F612F1-482B-42E2-8914-33ACCEAE60DE}">周</option>
							<%EndIf%>
							<%If !Exists("{586716EC-8BA7-4105-913A-039FB5918719}")%>
								<option value="{586716EC-8BA7-4105-913A-039FB5918719}">天</option>
							<%EndIf%>
						</select>
					</td>
				</tr>
				<tr>
					<th>名称：</th>
					<td><input type="text" name="Name" maxlength="50" class="Text <%=ContentLang%>Font" /></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">
HandleFake404();
</script>
</body>
</html>