<%@ Page Title="" Language="C#" MasterPageFile="~/Management/SiteManage.Master" AutoEventWireup="true"
    CodeBehind="ReplaceRule.aspx.cs" Inherits="BingoWebsiteCollector.Web.Management.ReplaceRule" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="right" style="text-align: center; margin-top: 10px;">
        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="edit">
            <tr>
                <td class="title_edit">
                    <h1 style="float: left">
                        <asp:Literal ID="ltEdit" runat="server" Text="编辑" Visible="false"></asp:Literal><asp:Literal ID="ltAdd" runat="server" Text="添加"></asp:Literal>替换规则</h1>
                </td>
            </tr>
            <tr>
                <td class="edit_main">
                    <asp:HiddenField ID="hfReplaceRuleId" runat="server" />
                            <table width="100%" border="0" cellspacing="1" cellpadding="1" class="table_list">
                                <tr>
                                    <td>
                                        <div align="right">
                                            规则名称：</div></td>
                                    <td align="left">
                                                    <asp:TextBox ID="tbName" runat="server" Width="80" Wrap="False" />
                                                </td>
                                        </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            优先级（优先级数小的规则最先生效）：</div></td>
                                    <td align="left">
                                        <asp:TextBox ID="tbPriority" runat="server" Text="1"
                                             Width="80" Wrap="False" />
                                        <validation targetid="<%=tbPriority.ClientID%>" targetname="优先级" type="number" />
                                             </td>
                                        </tr>
                                <tr>
                                    <td width="20%">
                                        <div align="right">
                                            替换前字符串 <font color="red">*</font>：</div>
                                    </td>
                                    <td align="left">
                                        <asp:TextBox ID="tbOldValue" runat="server" CausesValidation="True"
                                            EnableViewState="False" TextMode="MultiLine" Width="100%" Wrap="False" ValidationGroup="checkAdd" />
                                        <validation targetid="<%=tbOldValue.ClientID%>" targetname="替换前字符串" type="text" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            替换后字符串：</div>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="tbNewValue" runat="server"
                                            TextMode="MultiLine" Width="100%" Wrap="False" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            规则选项：</div>
                                    </td>
                                    <td align="left">
                                        <asp:CheckBox ID="cbIsEnable" CssClass="checkbox" runat="server" Checked="true"
                                            Text="是否激活" />
                                        <asp:CheckBox ID="cbIsRegex" CssClass="checkbox" runat="server"
                                            Text="是否正则表达式" />
                                        <asp:CheckBox ID="cbCaseSensitive" CssClass="checkbox" runat="server"
                                            Text="大小写敏感" />
                                    &nbsp;&nbsp;</td>
                                </tr>
                                <tr>
                                    <td>
                                        <div align="right">
                                            页面匹配：</div>
                                    </td>
                                    <td align="left">
                                            <fieldset>
                                            <legend>指定页面匹配</legend>
                                            <asp:CheckBox ID="cbMatchUrl" CssClass="checkbox" runat="server" onclick="$('#matchUrlParameter').toggle()"
                                            Text="规则用于指定页面（当前规则只对指定的页面生效）"  />
                                            <br />
                                                <div id="matchUrlParameter" style="display:<%=cbMatchUrl.Checked?string.Empty:"none"%>">
                                                    <asp:CheckBox ID="cbExactMatch" CssClass="checkbox" runat="server"
                                                    Text="是否精确匹配指定网址（对指定页面地址采取精确匹配或者模糊匹配，模糊匹配只要页面网址包含指定网址【这里是指原网页地址】，则规则生效）" 
                                                        ForeColor="Red" />
                                                    <br />
                                                    指定地址：
                                                    <asp:TextBox ID="tbUrl" runat="server" Width="80%" Wrap="False" />
                                                </div>
                                            </fieldset>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:Label ID="errorInfo" runat="server" Text="Label"></asp:Label>
                                        <asp:LinkButton ID="lbSubmit" runat="server" 
                                            Text="【提交】" onclick="lbSubmit_Click"  OnClientClick="return validateForm()" />
                                        &nbsp;<asp:LinkButton ID="lbCancel" runat="server" Text="【取消】" onclick="lbCancel_Click"/>
                                    </td>
                                </tr>
                            </table>
                </td>
            </tr>
        </table>
    </div>
    <div class="clear">
    </div>
        <div class="right" style="text-align: center; margin-top: 10px;">
        <div class="clear">
        </div>
        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="edit">
            <tr>
                <td class="title_edit">
                    <h1 style="float: left">
                        替换规则列表</h1>
                </td>
            </tr>
            <tr>
                <td class="edit_main">
                    <asp:GridView ID="gvReplaceRules" runat="server" AutoGenerateColumns="False" 
                        GridLines="None" CssClass="table_list" Width="100%" 
                        EnableModelValidation="True">
                        <Columns>
                            <asp:TemplateField HeaderText="操作" ShowHeader="False">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False"
                                        Text="【编辑】" CommandArgument='<%# Bind("RuleId") %>' onclick="lbEdit_Click"></asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="False" CommandArgument='<%# Bind("RuleId") %>'
                                        Text="【删除】" onclick="lbDelete_Click" OnClientClick="if(confirm('确认删除记录?')){eval(this.attributes['href'].value)}else{return false}"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Priority" HeaderText="优先级" 
                                SortExpression="Priority" />
                        <asp:CheckBoxField DataField="IsEnable" HeaderText="是否激活" SortExpression="IsEnable" />
                        <asp:BoundField DataField="Name" HeaderText="规则名称" SortExpression="Name" />
                            <asp:TemplateField HeaderText="替换前字符串" SortExpression="OldValue">
                                <ItemTemplate>
                                    <asp:TextBox ID="oldValue" runat="server" Text='<%# Bind("OldValue") %>' ReadOnly="true"
                                        TextMode="MultiLine" Width="300px" Wrap="False"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="替换后字符串" SortExpression="NewValue">
                                <ItemTemplate>
                                    <asp:TextBox ID="newValue" runat="server" Text='<%# Bind("NewValue") %>' ReadOnly="true"
                                        TextMode="MultiLine" Width="300px" Wrap="False"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CheckBoxField DataField="IsRegex" HeaderText="是否正则表达式" SortExpression="IsRegex" />
                            <asp:CheckBoxField DataField="CaseSensitive" HeaderText="大小写敏感" SortExpression="CaseSensitive" />
                            <asp:CheckBoxField DataField="MatchUrl" HeaderText="是否指定页面" SortExpression="MatchUrl" />
                            <asp:CheckBoxField DataField="ExactMatch" HeaderText="是否精确匹配地址" SortExpression="ExactMatch" />
                        </Columns>
                        <HeaderStyle CssClass="tr1" />
                        <RowStyle CssClass="tr_a" />
                        <AlternatingRowStyle CssClass="tr_b" />
                        <FooterStyle CssClass="dg_header" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
    <div class="clear" style="margin-top: 10px;">
    </div>
</asp:Content>
