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

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    &nbsp;<table style="width: 512px; height: 338px">
        <tr>
            <td align="right" style="width: 41px">
                <asp:Label ID="Label1" runat="server" Text="写日志" Width="64px"></asp:Label></td>
            <td align="left" colspan="1" valign="top" style="width: 449px">
                <asp:Label ID="Label2" runat="server" Width="378px"></asp:Label></td>
        </tr>
        <tr>
            <td align="right" colspan="2" style="height: 2px">
                <hr class="width85"/>
                &nbsp;</td>
        </tr>
        <tr>
            <td align="right" style="width: 41px; height: 336px">
            </td>
            <td align="left" style="width: 449px; height: 336px" valign="top">
                <asp:FormView ID="FormView1" runat="server" DataKeyNames="log_id" DataSourceID="SqlDataSource1"
        OnDataBound="FormView1_DataBound">
        <EditItemTemplate>
            log_id:
            <asp:Label ID="log_idLabel1" runat="server" Text='<%# Eval("log_id") %>'></asp:Label><br />
            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="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                Text="更新">
            </asp:LinkButton>
            <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="取消">
            </asp:LinkButton>
        </EditItemTemplate>
        <InsertItemTemplate>
            <table style="width: 414px; height: 248px">
                <tr>
                    <td align="left" colspan="2">
                        标题：</td>
                </tr>
                <tr>
                    <td align="left" colspan="2">
            <asp:TextBox ID="log_titleTextBox" runat="server" Text='<%# Bind("log_title") %>' ValidationGroup="a"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="log_titleTextBox"
                            ErrorMessage="日志标题不能为空" Style="position: static" ValidationGroup="a"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td align="left" colspan="2" style="height: 11px">
                        内容：&nbsp;</td>
                </tr>
                <tr>
                    <td align="left" colspan="2" style="height: 267px" valign="top">
                        &nbsp;<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Height="350px" Width="400px">
                        </FCKeditorV2:FCKeditor>
                    </td>
                </tr>
                <tr>
                    <td align="left" colspan="2" valign="top">
                        标签：<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
                DataTextField="category_name" DataValueField="category_id">
            </asp:DropDownList></td>
                </tr>
                <tr>
                    <td align="left" colspan="2" style="height: 11px">
                        隐藏：<asp:CheckBox ID="is_hideCheckBox" runat="server" Checked='<%# Bind("is_hide") %>' Width="116px" /></td>
                </tr>
                <tr>
                    <td align="left" colspan="1" style="width: 18px; height: 12px;" valign="top">
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                Text="发表日志" Width="73px" ValidationGroup="a" OnClick="InsertButton_Click"></asp:LinkButton>
                    </td>
                    <td align="left" style="width: 57px; height: 12px;" colspan="1" valign="top">
            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="重置" Width="32px"></asp:LinkButton>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="left" colspan="1" style="width: 18px" valign="top">
                    </td>
                    <td align="left" colspan="1" style="width: 57px" valign="top">
                        <asp:Label ID="Label3" runat="server" Width="250px"></asp:Label></td>
                </tr>
            </table>
            &nbsp;<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>
        </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>
    </table>
    <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, default, @category_id, @bloger_name, default, @is_hide)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [DE_logs]"
        UpdateCommand="UPDATE [DE_logs] SET [log_title] = @log_title, [contents] = @contents, [pub_date] = @pub_date, [category_id] = @category_id, [bloger_name] = @bloger_name, [click_count] = @click_count, [is_hide] = @is_hide 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" OnInserting="SqlDataSource1_Inserting">
        <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="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" />
            <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" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="log_title" Type="String" />
            <asp:Parameter Name="contents" Type="String" />
            <asp:Parameter Name="category_id" Type="Int32" />
            <asp:Parameter Name="bloger_name" Type="String" />
            <asp:Parameter Name="is_hide" Type="Boolean" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

