<%@ Page language="c#" Codebehind="Manager.aspx.cs" AutoEventWireup="true" Inherits="XpShop.Manage.Manager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
	<HEAD>
	    <!--#include file="inc/head.inc"-->
		<title>Manager</title>
		<link rel="stylesheet" type="text/css" media="screen" href="style/cmxform.css" />
		<script src="../inc/jquery.query.js" type="text/javascript"></script>
		<script src="../inc/jquery.validate.js" type="text/javascript"></script>
		<script src="../inc/jquery.metadata.js" type="text/javascript"></script>
		<script src="../inc/jquery.form.js" type="text/javascript"></script>
		<script src="../inc/messages_cn.js" type="text/javascript"></script>
		<script language="javascript">
		$(document).ready(function(){
		    $.validator.methods.strlen= function(value,element,param){
               var  str =$(element).val();
               var  len =0;
               for(var i=0;i<str.length;i++){
                  if(str.charCodeAt(i)>255){
                     len +=2;
                  }
                  else{
                     len +=1;
                  }
               }
               return (len -param)<=0;
	        }
	        $("#Form1").validate({
		        event: "keyup",
		        rules: {
			        txtAccount: {
				        required: true,
				        rangelength:[3,20]
			        },
			        txtRealName: {
			            required: true,
				        strlen:20
			        },
			        txtPassword: {
				        rangelength:[6,20]
			        }
		        },    		
		        messages: {
			        txtAccount: {
				        required: "请输入账号",
				        rangelength: "请输入3-12位的账号"
			        },
			        txtRealName: {
			            required: "请输入真实姓名",
				        strlen: "最多允许输入10个汉字20个字符)"
			        },
			        txtPassword: {
				        rangelength: "请输入6-20位的密码"
			        }
		        },
		        debug:"false",
		        submitHandler:function(form){
		            if($.query.get('aid') == "" && $("#txtPassword").val()==""){
		                alert("密码不能为空");
		                return;
		            }
			        form.submit();
		        }
	        });
	    });
		</script>
	</HEAD>
	<body>
	    <div class="container">
		<div class="sub_container">
		<div class="sub_container_title"><a href="<%=AdminDefault%>" target="_top">桌面</a><img src="images/admin_title.jpg" height=9px width=8px align="absmiddle" />
		    <% if (this.Request.QueryString["Action"] == "Manage")
         {%>管理员列表<%} if (this.Request.QueryString["Action"] == "Add" | this.Request.QueryString["Action"] == "Modify")
         {%>管理员添加<%}%>
	    </div>
		<div class="sub_container_content">
		<form class="cmxform" id="Form1" method="post" runat="server">
		<input id="hdFlag" type="hidden" name="flag" value="0" runat="server"/>
		    <div class="frame">
		        <div class="frame_title"><asp:Label id="lblAction" runat="server" CssClass="tableHeaderText"></asp:Label></div>
		        <div class="frame_content">
		            <% if (this.Request.QueryString["Action"] == "Manage")
                 {%>
			        <table class="tableBorder" cellSpacing="0" cellPadding="0" width="98%" align="center" border="0">
				        <tr>
					        <td height="23" class="forumRowHighlight">
						        <asp:datagrid id="dgAdmin" runat="server" AllowPaging="False" PagerStyle-Mode="NumericPages" AutoGenerateColumns="False"
							        DataKeyField="AdminID" Width="100%" HorizontalAlign="Center" HeaderStyle-CssClass="summary-title">
							        <HeaderStyle Font-Bold="True"></HeaderStyle>
							        <Columns>
								        <asp:TemplateColumn HeaderText="序号">
									        <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
									        <ItemStyle HorizontalAlign="Left" Width="60px"></ItemStyle>
									        <ItemTemplate>
										        <%# Container.ItemIndex + 1%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="帐号">
									        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
									        <ItemStyle HorizontalAlign="Center"></ItemStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "AdminName")%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="真实姓名">
									        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
									        <ItemStyle HorizontalAlign="Center"></ItemStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "RealName")%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="级别">
									        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
									        <ItemStyle HorizontalAlign="Center"></ItemStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "Flag").ToString() == "3" ? "超级管理员" : "普通管理员"%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="角色">
									        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
									        <ItemStyle HorizontalAlign="Center"></ItemStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "RoleName")%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="状态">
									        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
									        <ItemStyle HorizontalAlign="Center"></ItemStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "Status").ToString() == "1" ? "启用" : "禁用"%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="修改">
							                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
							                <ItemStyle HorizontalAlign="Center" Width="80px"></ItemStyle>
							                <ItemTemplate>
								                <a href='Manager.aspx?Action=Modify&aid=<%# DataBinder.Eval(Container.DataItem, "AdminID") %>'>修改</a>
							                </ItemTemplate>
						                </asp:TemplateColumn>
								        <asp:ButtonColumn HeaderText="删除" Text="&lt;div id=&quot;de&quot; onclick=&quot;javascript:return confirm('确认删除吗？')&quot;&gt;删除&lt;/div&gt;"
									        CommandName="Delete">
									        <ItemStyle HorizontalAlign="Center"></ItemStyle>
								        </asp:ButtonColumn>
							        </Columns>
							        <PagerStyle Mode="NumericPages"></PagerStyle>
						        </asp:datagrid>
					        </td>
				        </tr>
			        </table>
			        <%} if (this.Request.QueryString["Action"] == "Add" | this.Request.QueryString["Action"] == "Modify")
                 {%>
			        <table class="tableBorder" cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
				        <tr>
					        <td height="23">
						        <table class="ptable" cellSpacing="0" cellPadding="0" align="center" border="0">
							        <tr>
								        <th class="tl"><em>*</em>账号：</th>
								        <td class="tr">
									        <asp:TextBox id="txtAccount" runat="server"></asp:TextBox><span class="input-remark">3-12位的英文字母</span>
								        </td>
							        </tr>
							        <tr>
								        <th class="tl"><em>*</em>真实姓名：</th>
								        <td class="tr">
									        <asp:TextBox id="txtRealName" runat="server"></asp:TextBox><span class="input-remark">10个汉字以内</span>
								        </td>
							        </tr>
							        <tr>
								        <th class="tl"><em>*</em>密码：</th>
								        <td class="tr">
									        <asp:TextBox id="txtPassword" runat="server"></asp:TextBox><span class="input-remark">6-20位(修改管理员资料时留空则保留原有密码)</span>
								        </td>
							        </tr>
							        <tr>
								        <th class="tl">角色：</th>
								        <td class="tr">
                                            <asp:DropDownList ID="ddlRole" runat="server">
                                            </asp:DropDownList>
								        </td>
							        </tr>
							        <tr>
								        <th class="tl">状态：</th>
								        <td class="tr">
                                            <asp:DropDownList ID="ddlStatus" runat="server">
                                            <asp:ListItem Value="1">启用</asp:ListItem>
                                            <asp:ListItem Value="0">禁用</asp:ListItem>
                                            </asp:DropDownList>
								        </td>
							        </tr>
							        <tr>
								        <td colspan="2" class="center">
									        <asp:Button id="btnSave" OnClick="btnSave_Click" runat="server" Text="保存" CssClass="inputbtn"></asp:Button>
									    </td>
							        </tr>
						        </table>
					        </td>
				        </tr>
			        </table>
			        <%}%>
		        </div>
	        </div>
		</form>
		</div>
		</div>
		</div>
	</body>
</HTML>
