<%@ Page Language="C#" MasterPageFile="~/BlogerMasterPage.master" AutoEventWireup="true" CodeFile="EditLog.aspx.cs" Inherits="EditLog" Title="Untitled Page" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width: 418px; height: 126px">
        <tr>
            <td align="left" style="width: 9px; height: 10px;">
                <asp:Label ID="Label3" runat="server" Text="编辑日志" Width="86px"></asp:Label></td>
            <td align="left" style="width: 103px; height: 10px;">
                <asp:Label ID="Label5" runat="server" Width="394px"></asp:Label></td>
        </tr>
        <tr>
            <td align="left" colspan="2" style="height: 1px">
                <hr style="width: 505px; height: 1px" />
            </td>
        </tr>
        <tr>
            <td align="left" colspan="2" style="height: 322px" valign="top">
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="log_id" DataSourceID="SqlDataSource1"
        OnDataBound="FormView1_DataBound">
        <EditItemTemplate>
            <table style="width: 522px; height: 178px">
                <tr>
                    <td align="left" colspan="2">
                        <asp:Label ID="Label1" runat="server" Text="标题："></asp:Label></td>
                </tr>
                <tr>
                    <td align="left" colspan="2">
            <asp:TextBox ID="log_titleTextBox" runat="server" Text='<%# Bind("log_title") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="log_titleTextBox"
                            ErrorMessage="日志标题不能为空" Style="position: static" ValidationGroup="mm"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td align="left" colspan="2">
                        <asp:Label ID="Label2" runat="server" Text="内容："></asp:Label></td>
                </tr>
                <tr>
                    <td align="left" colspan="2" style="height: 132px" valign="top">
            <asp:TextBox ID="contentsTextBox" runat="server" Height="150px" Text='<%# Bind("contents") %>'
                Width="466px" TextMode="MultiLine"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="left" colspan="2">
                        标签：&nbsp;<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
                DataTextField="category_name" DataValueField="category_id" SelectedValue='<%# Bind("category_id") %>'>
            </asp:DropDownList></td>
                </tr>
                <tr>
                    <td align="left" colspan="2">
                        隐藏：<asp:CheckBox ID="is_hideCheckBox" runat="server" Checked='<%# Bind("is_hide") %>' /></td>
                </tr>
                <tr>
                    <td align="center" style="width: 56px; height: 18px;">
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                Text="更新" Width="50px" ValidationGroup="mm"></asp:LinkButton></td>
                    <td align="left" style="width: 100px; height: 18px;">
            <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="取消" Width="167px"></asp:LinkButton></td>
                </tr>
            </table>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConflictDetection="CompareAllValues"
                ConnectionString="<%$ ConnectionStrings:DesertEagleConnectionString %>" DeleteCommand="DELETE FROM [DE_category] WHERE [category_id] = @original_category_id AND [category_name] = @original_category_name AND [bloger_name] = @original_bloger_name"
                InsertCommand="INSERT INTO [DE_category] ([category_name], [bloger_name]) VALUES (@category_name, @bloger_name)"
                OldValuesParameterFormatString="original_{0}" OnSelecting="SqlDataSource2_Selecting"
                SelectCommand="SELECT * FROM [DE_category] WHERE ([bloger_name] = @bloger_name)"
                UpdateCommand="UPDATE [DE_category] SET [category_name] = @category_name, [bloger_name] = @bloger_name WHERE [category_id] = @original_category_id AND [category_name] = @original_category_name AND [bloger_name] = @original_bloger_name">
                <DeleteParameters>
                    <asp:Parameter Name="original_category_id" Type="Int32" />
                    <asp:Parameter Name="original_category_name" Type="String" />
                    <asp:Parameter Name="original_bloger_name" Type="String" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="category_name" Type="String" />
                    <asp:Parameter Name="bloger_name" Type="String" />
                    <asp:Parameter Name="original_category_id" Type="Int32" />
                    <asp:Parameter Name="original_category_name" Type="String" />
                    <asp:Parameter Name="original_bloger_name" Type="String" />
                </UpdateParameters>
                <SelectParameters>
                    <asp:Parameter Name="bloger_name" Type="String" />
                </SelectParameters>
                <InsertParameters>
                    <asp:Parameter Name="category_name" Type="String" />
                    <asp:Parameter Name="bloger_name" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
        </EditItemTemplate>
        <InsertItemTemplate>
            log_title:
            <asp:TextBox ID="log_titleTextBox" runat="server" Text='<%# Bind("log_title") %>'>
            </asp:TextBox><br />
            contents:
            <asp:TextBox ID="contentsTextBox" runat="server" Text='<%# Bind("contents") %>'>
            </asp:TextBox><br />
            pub_date:
            <asp:TextBox ID="pub_dateTextBox" runat="server" Text='<%# Bind("pub_date") %>'>
            </asp:TextBox><br />
            category_id:
            <asp:TextBox ID="category_idTextBox" runat="server" Text='<%# Bind("category_id") %>'>
            </asp:TextBox><br />
            bloger_name:
            <asp:TextBox ID="bloger_nameTextBox" runat="server" Text='<%# Bind("bloger_name") %>'>
            </asp:TextBox><br />
            click_count:
            <asp:TextBox ID="click_countTextBox" runat="server" Text='<%# Bind("click_count") %>'>
            </asp:TextBox><br />
            is_hide:
            <asp:CheckBox ID="is_hideCheckBox" runat="server" Checked='<%# Bind("is_hide") %>' /><br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                Text="插入">
            </asp:LinkButton>
            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="取消">
            </asp:LinkButton>
        </InsertItemTemplate>
        <ItemTemplate>
            log_id:
            <asp:Label ID="log_idLabel" runat="server" Text='<%# Eval("log_id") %>'></asp:Label><br />
            log_title:
            <asp:Label ID="log_titleLabel" runat="server" Text='<%# Bind("log_title") %>'></asp:Label><br />
            contents:
            <asp:Label ID="contentsLabel" runat="server" Text='<%# Bind("contents") %>'></asp:Label><br />
            pub_date:
            <asp:Label ID="pub_dateLabel" runat="server" Text='<%# Bind("pub_date") %>'></asp:Label><br />
            category_id:
            <asp:Label ID="category_idLabel" runat="server" Text='<%# Bind("category_id") %>'></asp:Label><br />
            bloger_name:
            <asp:Label ID="bloger_nameLabel" runat="server" Text='<%# Bind("bloger_name") %>'></asp:Label><br />
            click_count:
            <asp:Label ID="click_countLabel" runat="server" Text='<%# Bind("click_count") %>'></asp:Label><br />
            is_hide:
            <asp:CheckBox ID="is_hideCheckBox" runat="server" Checked='<%# Bind("is_hide") %>'
                Enabled="false" /><br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="编辑"></asp:LinkButton>
            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                Text="删除"></asp:LinkButton>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                Text="新建"></asp:LinkButton>
        </ItemTemplate>
    </asp:FormView>
            </td>
        </tr>
        <tr>
            <td align="left" style="width: 9px; height: 19px;" valign="top">
                <asp:Label ID="Label4" runat="server" Text="管理评论" Width="82px"></asp:Label></td>
            <td align="left" style="width: 103px; height: 19px;" valign="top">
            </td>
        </tr>
        <tr>
            <td align="left" colspan="2" style="height: 1px">
                <hr style="width: 525px" />
            </td>
        </tr>
        <tr>
            <td align="center" colspan="1" style="width: 9px">
            </td>
            <td align="left" colspan="3" style="width: 467px">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
        DataKeyNames="comment_id" DataSourceID="SqlDataSource3" ForeColor="#333333" GridLines="None" Height="10px" Width="394px" AllowPaging="True" PageSize="4">
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:BoundField DataField="comment_id" HeaderText="comment_id" InsertVisible="False"
                ReadOnly="True" SortExpression="comment_id" Visible="False" />
            <asp:BoundField DataField="contents" HeaderText="评论" SortExpression="contents" />
            <asp:BoundField DataField="author" HeaderText="评论者" SortExpression="author" />
            <asp:BoundField DataField="pub_date" DataFormatString="{0:yyyy-MM-dd}" HeaderText="评论时间"
                SortExpression="pub_date" HtmlEncode="False" />
            <asp:BoundField DataField="log_id" HeaderText="log_id" SortExpression="log_id" Visible="False" />
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="删除" OnClientClick='return confirm("确认删除？")'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>            
        </Columns>
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" Height = "20px"/>
        <EditRowStyle BackColor="#999999" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
            </td>
        </tr>
    </table>
    &nbsp;
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:DesertEagleConnectionString %>" DeleteCommand="DELETE FROM [DE_logs] WHERE [log_id] = @original_log_id AND [log_title] = @original_log_title AND [contents] = @original_contents AND [pub_date] = @original_pub_date AND [category_id] = @original_category_id AND [bloger_name] = @original_bloger_name AND [click_count] = @original_click_count AND [is_hide] = @original_is_hide"
        InsertCommand="INSERT INTO [DE_logs] ([log_title], [contents], [pub_date], [category_id], [bloger_name], [click_count], [is_hide]) VALUES (@log_title, @contents, @pub_date, @category_id, @bloger_name, @click_count, @is_hide)"
        OldValuesParameterFormatString="original_{0}" OnInserting="SqlDataSource1_Inserting"
        OnSelecting="SqlDataSource1_Selecting" OnUpdating="SqlDataSource1_Updating" SelectCommand="SELECT * FROM [DE_logs] WHERE ([log_id] = @log_id)"
        UpdateCommand="UPDATE [DE_logs] SET [log_title] = @log_title, [contents] = @contents, [pub_date] = default, [category_id] = @category_id, [is_hide] = @is_hide WHERE [log_id] = @original_log_id">
        <DeleteParameters>
            <asp:Parameter Name="original_log_id" Type="Int32" />
            <asp:Parameter Name="original_log_title" Type="String" />
            <asp:Parameter Name="original_contents" Type="String" />
            <asp:Parameter Name="original_pub_date" Type="DateTime" />
            <asp:Parameter Name="original_category_id" Type="Int32" />
            <asp:Parameter Name="original_bloger_name" Type="String" />
            <asp:Parameter Name="original_click_count" Type="Int32" />
            <asp:Parameter Name="original_is_hide" Type="Boolean" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="log_title" Type="String" />
            <asp:Parameter Name="contents" Type="String" />
            <asp:Parameter Name="category_id" Type="Int32" />
            <asp:Parameter Name="is_hide" Type="Boolean" />
            <asp:Parameter Name="original_log_id" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:Parameter Name="log_id" Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="log_title" Type="String" />
            <asp:Parameter Name="contents" Type="String" />
            <asp:Parameter Name="pub_date" Type="DateTime" />
            <asp:Parameter Name="category_id" Type="Int32" />
            <asp:Parameter Name="bloger_name" Type="String" />
            <asp:Parameter Name="click_count" Type="Int32" />
            <asp:Parameter Name="is_hide" Type="Boolean" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:DesertEagleConnectionString %>" DeleteCommand="DELETE FROM [DE_comment] WHERE [comment_id] = @original_comment_id"
        InsertCommand="INSERT INTO [DE_comment] ([contents], [author], [pub_date], [log_id]) VALUES (@contents, @author, @pub_date, @log_id)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [DE_comment] WHERE ([log_id] = @log_id)"
        UpdateCommand="UPDATE [DE_comment] SET [contents] = @contents, [author] = @author, [pub_date] = @pub_date, [log_id] = @log_id WHERE [comment_id] = @original_comment_id AND [contents] = @original_contents AND [author] = @original_author AND [pub_date] = @original_pub_date AND [log_id] = @original_log_id">
        <DeleteParameters>
            <asp:Parameter Name="original_comment_id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="contents" Type="String" />
            <asp:Parameter Name="author" Type="String" />
            <asp:Parameter Name="pub_date" Type="DateTime" />
            <asp:Parameter Name="log_id" Type="Int32" />
            <asp:Parameter Name="original_comment_id" Type="Int32" />
            <asp:Parameter Name="original_contents" Type="String" />
            <asp:Parameter Name="original_author" Type="String" />
            <asp:Parameter Name="original_pub_date" Type="DateTime" />
            <asp:Parameter Name="original_log_id" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="log_id" QueryStringField="log_id" Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="contents" Type="String" />
            <asp:Parameter Name="author" Type="String" />
            <asp:Parameter Name="pub_date" Type="DateTime" />
            <asp:Parameter Name="log_id" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

