<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
            AutoGenerateRows="False" BackColor="#DEBA84" BorderColor="#DEBA84" 
            BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" 
            DataKeyNames="AdminID" DataSourceID="SqlDataSource1" Height="50px" 
            Width="255px">
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <Fields>
                <asp:BoundField DataField="AdminID" HeaderText="用户编号" InsertVisible="False" 
                    ReadOnly="True" SortExpression="AdminID" />
                <asp:BoundField DataField="AdminName" HeaderText="用户名" 
                    SortExpression="AdminName" />
                <asp:BoundField DataField="Password" HeaderText="密码" 
                    SortExpression="Password" />
                <asp:BoundField DataField="sex" HeaderText="性别" SortExpression="sex" />
                <asp:BoundField DataField="department" HeaderText="所属部门" 
                    SortExpression="department" />
                <asp:CommandField HeaderText="编辑" ShowDeleteButton="True" ShowEditButton="True" 
                    ShowInsertButton="True" />
            </Fields>
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:BlogConnectionString %>" 
            DeleteCommand="DELETE FROM [Admins] WHERE [AdminID] = @AdminID" 
            InsertCommand="INSERT INTO [Admins] ([AdminName], [Password], [sex], [department]) VALUES (@AdminName, @Password, @sex, @department)" 
            SelectCommand="SELECT * FROM [Admins]" 
            UpdateCommand="UPDATE [Admins] SET [AdminName] = @AdminName, [Password] = @Password, [sex] = @sex, [department] = @department WHERE [AdminID] = @AdminID">
            <DeleteParameters>
                <asp:Parameter Name="AdminID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="AdminName" Type="String" />
                <asp:Parameter Name="Password" Type="String" />
                <asp:Parameter Name="sex" Type="String" />
                <asp:Parameter Name="department" Type="String" />
                <asp:Parameter Name="AdminID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="AdminName" Type="String" />
                <asp:Parameter Name="Password" Type="String" />
                <asp:Parameter Name="sex" Type="String" />
                <asp:Parameter Name="department" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
