<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UsersManager.aspx.cs" Inherits="ResMangSys.UsersManager" %>

<!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 runat="server">
    <title>用户管理</title>
    <style type="text/css">
    #content
    {
    	position:absolute; height:80%; width:80%; left:20%; right:10%; top:15%; margin-top:2px; margin-bottom:2px; 
    	}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <center><h2>用户管理</h2></center>
    <hr />
        <asp:ObjectDataSource ID="ODSUsers" runat="server" DeleteMethod="Delete" 
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetData" 
            TypeName="ResMangSys.DAL.UsersTableAdapters.T_UsersTableAdapter" 
            UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="Original_Id" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="UserName" Type="String" />
                <asp:Parameter Name="UserPwd" Type="String" />
                <asp:Parameter Name="Role" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="UserName" Type="String" />
                <asp:Parameter Name="UserPwd" Type="String" />
                <asp:Parameter Name="Role" Type="String" />
                <asp:Parameter Name="Original_Id" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
    <div id="content">
        <asp:ListView ID="LVUsers" runat="server" DataKeyNames="Id" 
            DataSourceID="ODSUsers" EnableModelValidation="True" 
            InsertItemPosition="LastItem" onitemcreated="LVUsers_ItemCreated" 
            oniteminserting="LVUsers_ItemInserting" onitemupdating="LVUsers_ItemUpdating">
          <%--  <AlternatingItemTemplate>
                <tr style="background-color:#FFF8DC;">
                    <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="删除" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="编辑" />
                    </td>
                    <td>
                        <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
                    </td>
                    <td>
                        <asp:Label ID="UserPwdLabel" runat="server" Text='<%# Eval("UserPwd") %>' />
                    </td>
                    <td>
                        <asp:Label ID="RoleLabel" runat="server" Text='<%# Eval("Role") %>' />
                    </td>
                </tr>
            </AlternatingItemTemplate>--%>
            <EditItemTemplate>
                <tr style="background-color:#008A8C;color: #FFFFFF;">
                    <td>
                        <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
                    </td>
                    <td>
                        <asp:TextBox ID="UserNameTextBox" runat="server" 
                            Text='<%# Bind("UserName") %>' />
                    </td>
                    <td>
                        <asp:TextBox ID="UserPwdTextBox" runat="server" Text='<%# Bind("UserPwd") %>' />
                    </td>
                    <td>
                    <asp:DropDownList ID="ddlRole" runat="server">
                        <asp:ListItem Value="manager">管理员</asp:ListItem>
                        <asp:ListItem Value="advUser">高级用户</asp:ListItem>
                        <asp:ListItem Value="user">普通用户</asp:ListItem>
                        </asp:DropDownList>
                        <%--<asp:TextBox ID="RoleTextBox" runat="server" Text='<%# Bind("Role") %>' />--%>
                    </td>
                </tr>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <table runat="server" 
                    style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                    <tr>
                        <td>
                            未返回数据。</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <tr style="">
                    <td>
                        <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" />
                    </td>
                    <td>
                        <asp:TextBox ID="UserNameTextBox" runat="server" 
                            Text='<%# Bind("UserName") %>' />
                    </td>
                    <td>
                        <asp:TextBox ID="UserPwdTextBox" runat="server" Text='<%# Bind("UserPwd") %>' />
                    </td>
                    <td>
                    <asp:DropDownList ID="ddlRole" runat="server" >
                        <asp:ListItem Value="manager">管理员</asp:ListItem>
                        <asp:ListItem Value="advUser">高级用户</asp:ListItem>
                        <asp:ListItem Selected="True" Value="user">普通用户</asp:ListItem>
                        </asp:DropDownList>
                        <%--<asp:TextBox ID="RoleTextBox" runat="server" Text='<%# Bind("Role") %>' />--%>
                    </td>
                </tr>
            </InsertItemTemplate>
            <ItemTemplate>
                <tr style="background-color:#DCDCDC;color: #000000;">
                    <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="删除" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="编辑" />
                    </td>
                    <td>
                        <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
                    </td>
                    <td>
                        <asp:Label ID="UserPwdLabel" runat="server" Text='<%# Eval("UserPwd") %>' />
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlRole" runat="server" Enabled="false">
                        <asp:ListItem Value="manager">管理员</asp:ListItem>
                        <asp:ListItem Value="advUser">高级用户</asp:ListItem>
                        <asp:ListItem Value="user">普通用户</asp:ListItem>
                        </asp:DropDownList><%--
                        <asp:Label ID="RoleLabel" runat="server" Text='<%# Eval("Role") %>' />--%>
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table runat="server">
                    <tr runat="server">
                        <td runat="server">
                            <table ID="itemPlaceholderContainer" runat="server" border="1" 
                                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                                <tr runat="server" style="background-color:#DCDCDC;color: #000000;">
                                    <th runat="server">
                                    </th>
                                    <th runat="server">
                                        用户名</th>
                                    <th runat="server">
                                        密码</th>
                                    <th runat="server">
                                        角色</th>
                                </tr>
                                <tr ID="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr runat="server">
                        <td runat="server" 
                            style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                            <asp:DataPager ID="DataPager1" runat="server">
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    <asp:NumericPagerField />
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
                    <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="删除" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="编辑" />
                    </td>
                    <td>
                        <asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' />
                    </td>
                    <td>
                        <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
                    </td>
                    <td>
                        <asp:Label ID="UserPwdLabel" runat="server" Text='<%# Eval("UserPwd") %>' />
                    </td>
                    <td>
                        <asp:Label ID="RoleLabel" runat="server" Text='<%# Eval("Role") %>' />
                    </td>
                </tr>
            </SelectedItemTemplate>
        </asp:ListView>
    </div>
    </div>
    </form>
</body>
</html>
