<%@ Page Title="投票类别" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Vote_Category.aspx.cs" Inherits="Vote.Admin.Vote_Category" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


   
<div class="result-wrap">
      
                <div class="result-title">
                   
                        <a href="#"  class="btn btn-primary " id="a_addnew">新建类别</a>


                        <asp:LinkButton ID="lb_delete" class="btn btn-danger" 
                         OnClientClick="if(!isselect()) return false; " 
                        runat="server" onclick="lb_delete_Click">批量删除</asp:LinkButton> 
                     
                        
                         <asp:LinkButton ID="lb_update_order" runat="server"  CssClass="btn btn-default"
                            onclick="lb_update_order_Click">
                                                  更新排序

                            </asp:LinkButton>

                          
                </div>
 



  <div id="thenew" style="display:none" class="result-content"> 


    <table class="table" width="100%">
                        <tbody> 
                            <tr>
                                <th><i class="require-red">*</i>类别名称：</th>
                                <td>
                                   
                                    <asp:TextBox class="form-control"  ValidationGroup="Add" ID="txt_catname" Text="" Width=300px runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ValidationGroup="Add" ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写类别" ControlToValidate="txt_catname" Display="Static"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <th>排序数字：</th>
                                <td>
                                    <asp:TextBox class="common-text" ID="txt_orderid" Text="0" Width=300px runat="server"></asp:TextBox>
                             </td>
                            </tr>
                            
                            <tr>
                                <th></th>
                                <td>
                                    <asp:Button ID="btn_add" runat="server" Text="提交"  ValidationGroup="Add" 
                                        class="btn btn-primary btn6 mr10" onclick="btn_add_Click" />
 
                                    <input class="btn btn6"  id="btn_back" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>

  </div>

 
  <div id="thetable" class="result-content"> 
                    
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  AllowPaging="true"  PageSize=20
     class="table" width="100%" GridLines="None"
     DataKeyNames="id" DataSourceID="SqlDataSource1">
       
       
        <Columns> 
  <asp:TemplateField> 
        <HeaderTemplate> 
              <asp:CheckBox ID="chk_SelectedHeader" runat="server" AutoPostBack="False" onclick="selectall(this)"  /> 
         </HeaderTemplate> 
                            
         <ItemTemplate  > 
            <input type="checkbox"  class="ck_item"   title=<%# Eval("id") %> value='<%# Eval("id") %>'  /> 
            <asp:HiddenField runat="server" ID="hf_id" Value=<%# Eval("id") %> /> 
          </ItemTemplate>    
          <HeaderStyle  Width=60px  CssClass="tc"/>        
       

          </asp:TemplateField>
                        

         <asp:TemplateField>
         <HeaderTemplate>排序</HeaderTemplate>
          <ItemTemplate>
            <asp:TextBox runat="server"  Width=60px Text='<%#Bind("orderId") %>' ID="txt_orderid"></asp:TextBox>
          </ItemTemplate>
           <HeaderStyle   /> 
         </asp:TemplateField> 

      

         <asp:BoundField DataField="name"   ItemStyle-Width="600px" HeaderText="类别名称" SortExpression="name" />

      <asp:CommandField HeaderText="操作" EditText="编辑" DeleteText="<span onclick=&quot;JavaScript:return confirm('确定删除吗？')&quot;>删除</span> "  UpdateText="更新"  CancelText="取消" ShowDeleteButton="True" ShowEditButton="True" />

          
        </Columns>
        
          
    
    </asp:GridView>









                </div>
            
        </div>












        






        <asp:SqlDataSource ID="SqlDataSource1"  
           ConnectionString='<%$ ConnectionStrings:ConnectionString %>'
           Runat="server" 
           DeleteCommand="DELETE FROM [Vote_Category] WHERE [id] = @id" 
           InsertCommand="INSERT INTO [vote_category] ([name], [orderid]) VALUES (@name, @orderid)" 
           SelectCommand="SELECT * FROM [vote_category] order by orderid asc " 
           UpdateCommand="UPDATE [vote_category] SET [name] = @name, [orderid] = @orderid WHERE [id] = @id"  >
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="orderid" Type="Int32" DefaultValue="0" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="orderid" Type="Int32" DefaultValue="0" />
        </InsertParameters>
    </asp:SqlDataSource>
 
     <input type="hidden" name="hf_ids" id="hf_ids" />







     <script>


         $(document).ready(

         function () {
             $("#a_addnew").click(
             function () {
                 $("#thenew").show();
                 $("#thetable").hide();
             }
             );

             $("#btn_back").click( 
             function () {
                 $("#thenew").hide();
                 $("#thetable").show();
             }
             );

         }

         );


        
     
     </script>



      


</asp:Content>
