<%@ Page Language="c#" Inherits="TopWinCMS.WebUI.Admin.Admin_Admin" CodeBehind="Admin.aspx.cs" %>

<%@ Register Src="../UC_AjaxLoading.ascx" TagName="UC_AjaxLoading" TagPrefix="uc1" %>
<%@ Register Assembly="TopWinCMS.WebControls" Namespace="TopWinCMS.WebControls" TagPrefix="cc1" %>
<!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>
    <title>管理员管理</title>
    <meta http-equiv="Pragma" content="No-cach" />
    <link href="../Style.css" type="text/css" rel="stylesheet" />
    <script language="javascript" type="text/javascript" src="../TopWin.js"></script>
    <script language="javascript" type="text/javascript" src="../../Images/skysoft.js"></script>

    <script type="text/javascript" language="javascript">
    function CheckPSW1()
	{ 
	    if(document.getElementById("TB_OldPSW").value=="")
	    {
	        alert("请输入旧密码！！");
	        return false;
	    }
	    if (document.getElementById("TB_New_PSW1").value==""||document.getElementById("TB_New_PSW2").value=="")
	    {
	        alert("密码不能为空。");
	        return false;
	    }
	    
		if (document.getElementById("TB_New_PSW1").value!=document.getElementById("TB_New_PSW2").value)
		{
			alert("两个密码不匹配！！");
			document.getElementById("TB_New_PSW1").focus();
			return false;
		}
	}
	function CheckPSW2()
	{ 
	    if(document.getElementById("TB_UserName").value=="")
	    {
	        alert("请输入用户名！！");
	        return false;
	    }
	    if (document.getElementById("TB_Password1").value==""||document.getElementById("TB_Password2").value=="")
	    {
	        alert("密码不能为空。");
	        return false;
	    }
	    
		if (document.getElementById("TB_Password1").value!=document.getElementById("TB_Password2").value)
		{
			alert("两个密码不匹配！！");
			document.getElementById("TB_Password1").focus();
			return false;
		}
	}
    </script>

</head>
<body>
    <form id="Form1" method="post" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <uc1:UC_AjaxLoading ID="UC_AjaxLoading1" runat="server"></uc1:UC_AjaxLoading>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="Panel1" runat="server" Visible="False">
                <table cellspacing="0" cellpadding="0" width="300" align="center" border="0">
                    <tr>
                        <td width="100%" height="23" class="HeaderStyle">
                            <b>修改密码</b>
                        </td>
                    </tr>
                    <tr>
                        <td class="border" height="23">
                            <table cellspacing="1" cellpadding="1" width="100%" border="0">
                                <tr class="border">
                                    <td align="right" height="19">
                                        用户名：
                                    </td>
                                    <td height="19">
                                        <asp:Label ID="LB_UserName" runat="server" />
                                    </td>
                                </tr>
                                <tr class="border">
                                    <td align="right">
                                        他的旧密码：
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TB_OldPSW" runat="server" TextMode="Password" />
                                        <span style="color: #ff0000">*</span>
                                    </td>
                                </tr>
                                <tr class="border">
                                    <td align="right">
                                        他的新密码：
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TB_New_PSW1" runat="server" TextMode="Password">
                                        </asp:TextBox>
                                        <span style="color: #ff0000">*</span>
                                    </td>
                                </tr>
                                <tr class="border">
                                    <td align="right">
                                        确定新密码：
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TB_New_PSW2" runat="server" TextMode="Password">
                                        </asp:TextBox>
                                        <span style="color: #ff0000">*</span>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                </BR>
                <asp:Button ID="BT_ChangePSW" runat="server" Text="确定" OnClick="BT_ChangePSW_Click"
                    EnableViewState="False" CssClass="btn" />&nbsp;&nbsp;
                <input style="cursor:pointer" onclick="window.location.href='Admin.aspx'" type="button"
                    value="返回" class="btn" />
                <br />
                <br />
                <asp:Label ID="LB_Message" runat="server" Font-Bold="True"></asp:Label>

            </asp:Panel>
            &nbsp;&nbsp;&nbsp;
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
        <ProgressTemplate>
            <uc1:UC_AjaxLoading ID="UC_AjaxLoading2" runat="server"></uc1:UC_AjaxLoading>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
            <asp:Panel ID="Panel3" runat="server">
            <asp:GridView ID="GV_List" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="GV_List_RowCancelingEdit"
                OnRowDataBound="GV_List_RowDataBound" OnRowDeleting="GV_List_RowDeleting" OnRowEditing="GV_List_RowEditing"
                OnRowUpdating="GV_List_RowUpdating" AllowPaging="True" DataKeyNames="ID">
                <Columns>
                    <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="true">
                        <ItemStyle Width="40px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="UserName" ReadOnly="true" HeaderText="用户名" />
                    <asp:TemplateField HeaderText="角色">
                        <EditItemTemplate>
                            <asp:DropDownList ID="DropDownList2" runat="server" DataValueField="ID" DataTextField="RoleName"
                                DataSource="<%#  LoadRole()%>" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("RoleName") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:BoundField DataField="LastLoginIP"  ReadOnly="true" HeaderText="最后登录IP">
                        <ItemStyle Width="80px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="LastLoginTime" DataFormatString="{0:yy-MM-dd HH:mm:ss}"
                        HeaderText="最后登录时间" HtmlEncode="False"  ReadOnly="true">
                        <ItemStyle HorizontalAlign="Center" Width="106px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="LastLogoutTime" DataFormatString="{0:yy-MM-dd HH:mm:ss}"
                        HeaderText="最后退出时间" ReadOnly="true">
                        <ItemStyle HorizontalAlign="Center" Width="106px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="LoginTimes" HeaderText="登录次数" ReadOnly="true">
                        <ItemStyle HorizontalAlign="Right" Width="60px" />
                    </asp:BoundField>
                    <asp:HyperLinkField DataNavigateUrlFields="UserName" DataNavigateUrlFormatString="Admin.aspx?Action=ModifyPwd&amp;UserName={0}"
                        HeaderText="修改密码" Text="修改密码">
                        <ItemStyle HorizontalAlign="Center" Width="60px" />
                    </asp:HyperLinkField>
                    <asp:CommandField EditImageUrl="~/Admin/Images/Edit.gif" ShowEditButton="True">
                        <ItemStyle HorizontalAlign="Center" Width="60px" />
                    </asp:CommandField>
                    <asp:CommandField ButtonType="Link" DeleteImageUrl="~/Admin/Images/del.gif" DeleteText="删除"
                        ShowDeleteButton="True">
                        <ItemStyle HorizontalAlign="Center" Width="26px" />
                    </asp:CommandField>
                </Columns>
                <HeaderStyle CssClass="HeaderStyle" />
                <PagerSettings Visible="False" />
            </asp:GridView>
            <div class="pagefield">
                <cc1:PageNavigation ID="PageNavigation1" runat="server" OnPageChanging="PageNavigation1_PageChanging"
                    SubmitButtonClass="btn">
                </cc1:PageNavigation>
            </div>  </asp:Panel>
            <asp:Panel ID="Panel2" runat="server" Visible="False">
                <table cellspacing="0" cellpadding="0" width="100%" border="0">
                    <tr class="HeaderStyle">
                        <td>
                            管理员添加
                        </td>
                    </tr>
                    <tr>
                        <td  class="border">
                            <table cellspacing="0" width="98%" align="center" border="0">
                                <tr>
                                    <td width="111">
                                        <strong>用 户 名：</strong>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TB_UserName" runat="server" Width="146px">
                                        </asp:TextBox>
                                        <span style="color: #ff0000">*</span>
                                    </td>
                                    <td colspan="2">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td width="111">
                                        <strong>初始密码： </strong>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TB_Password1" runat="server" TextMode="Password">
                                        </asp:TextBox>
                                        <span style="color: #ff0000">*</span>
                                    </td>
                                    <td width="93">
                                        <strong>确认密码：</strong>
                                    </td>
                                    <td>
                                        <font size="2">&nbsp;
                                            <asp:TextBox ID="TB_Password2" runat="server" TextMode="Password">
                                            </asp:TextBox>
                                            <span style="color: #ff0000">*</span></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="111" rowspan="2">
                                        <strong>角&nbsp; 色： </strong>
                                    </td>
                                    <td width="234" rowspan="2">
                                        <asp:DropDownList ID="DDL_RoleID" runat="server">
                                        </asp:DropDownList>
                                    
                                        </td>
                                    <td colspan="2" height="25">
                                        请选择要添加的管理员的“角色”。
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        “角色”详细指定每一项管理权限，被赋予该“角色”以后，他就拥有该“角色”的权力，一但改变“角色”的权力，那么所有属于该“角色”的管理员的权力都跟着改变。
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <div align="center">
                    <br />
                    <asp:Button ID="Bt_AddAdmin" runat="server" Text="添加" OnClick="BT_AddAdmin_Click"
                        CssClass="btn"></asp:Button>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input style="cursor: hand" onclick="window.location.href='Admin.aspx'" type="button"
                        value="返回" class="btn"> </input>
                    </BR>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
