<%@ Page Title="" Language="C#" MasterPageFile="~/bps/bps.Master" AutoEventWireup="true" CodeBehind="material_cat_2.aspx.cs" Inherits="purchase.purchase.Product_Cat2" %>
<%@ Register src="../UserControl/CatTab.ascx" tagname="CatTab" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     
      <h1  class="border-active subnav" ><%=isen?"Material List":"原料列表" %>  </h1>


     <uc1:CatTab ID="CatTab" runat="server"  currentindex="2" />
     



    <div class="content">


        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

 
                    
<table class="table" style="width:1000px" >
   <tbody>
           
              <tr>
               <td>
一级分类：
               </td>
               <td>

                   <asp:DropDownList runat="server" ID="ddl_category1"  CssClass="form-control"  AutoPostBack="true" OnSelectedIndexChanged="ddl_parentcat_SelectedIndexChanged"></asp:DropDownList>
               </td>
           </tr>
         <tr >     
                
         <td  class="td_left" width="20%">二级分类:</td>
          <td width="50%" class="td_right"> 
              <asp:TextBox ID="txt_catname" ValidationGroup="add"   CssClass="form-control" runat="server"></asp:TextBox>
          
              <asp:RequiredFieldValidator ForeColor="red" ValidationGroup="add"  ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写类别名称" ControlToValidate="txt_catname" Display="Dynamic"></asp:RequiredFieldValidator>
              
               </td>
             <td>
                 如 笔类
             </td>
           
            </tr>
            
  
         <tr >     
                
         <td  class="td_left" >小类拼音:</td>
          <td   class="td_right"> 
              <asp:TextBox ID="txt_pinyin"   CssClass="form-control" runat="server"></asp:TextBox>
              
           </td>
             <td>
                如 BL 如为空则系统计算拼音
             </td>
           
            </tr>
            
   
        
         <tr bgColor=#ffffff>     
                <td colspan="3" align="center"> 
                    
                <asp:Button runat="server" ID="add" OnClick="btnAdd_Click"  ValidationGroup="add"   CssClass="btn btn-danger btn-flat btn-sm" Text="添加类别"/>

                                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:void(0);" onclick="ept('Export_Data.aspx?types=cat')" class="btn  btn-sm btn-primary  btn-flat"> 导出所有分类</a>
                </td>
            </tr>
            
            
      
          </tbody>
          </table>

     



  <asp:GridView runat="server"
                    
                    
                     ID="gv_list" AllowPaging="True" GridLines="None" CssClass="table" PageSize="30" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="id" OnRowUpdating="gv_list_RowUpdating">
                    <Columns>

                        <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" Visible="false" SortExpression="id"  HeaderStyle-Width="100"/>
                        <asp:BoundField DataField="catname" HeaderText="类别名称" SortExpression="catname" HeaderStyle-Width="200"/>

                        <asp:BoundField DataField="pinyin" HeaderText="类别拼音" SortExpression="pinyin" HeaderStyle-Width="300"/>

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


                                               
                    </Columns>
                </asp:GridView>

                <asp:SqlDataSource ID="SqlDataSource1"
                     ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                     runat="server" DeleteCommand="DELETE FROM [purchase_categories] WHERE [id] = @id"
                    SelectCommand="SELECT [id], [catname], [parentid], [pinyin] FROM [purchase_categories] WHERE ([iscat] = 1) and (parentid=@pid) ORDER BY [id]" 
                    UpdateCommand="UPDATE [purchase_categories] SET [catname] = @catname,   [pinyin] = @pinyin WHERE [id] = @id" OnUpdating="SqlDataSource1_Updating" OnDeleting="SqlDataSource1_Deleting" >
                   
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddl_category1" ConvertEmptyStringToNull="false"  Name="pid"/>

                    </SelectParameters>

                     <DeleteParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                    </DeleteParameters>
                     
                    <UpdateParameters>
                        <asp:Parameter Name="catname" Type="String" />                        
                        <asp:Parameter Name="pinyin" Type="String" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>

            </ContentTemplate>

        </asp:UpdatePanel>

    </div>











</asp:Content>
