﻿<%@ Page Title="" Language="C#" MasterPageFile="step.Master" AutoEventWireup="true" CodeBehind="Add_question.aspx.cs" Inherits="exam.tech.Add_question" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 <style>
     .qestypes{ font-size:12px; color:#01AAED }
     .questpoints{ font-size:12px; font-weight:bold; }
 </style>    
           <script  id="MathJax-script" async  src="../javascript/mathjax/tex-mml-chtml.js"></script>
<div style=" padding:20px;">
 
   <h4>添加分部</h4>
     
        
         
                    <a href="###"  onclick="Pop('pop_question.aspx?activeid=<%=activeid%>',1000,600,'选择试题');" class="layui-btn layui-bg-blue">从题库选择试题</a>

         
  
    <hr />

    <table class="layui-table">
      <tr>
          <td width="100px">
              类型
          </td>
           <td>
题目
          </td>

          <td>
              分数
          </td>

          <td>
              移除
          </td>
      </tr>

      
    <asp:Repeater runat="server" ID="rpt" DataSourceID="SqlDataSource1">
        <ItemTemplate>
              <tr>
<td > 
    <span class="qestypes">
        <span class="idx  <%#Eval("types").ToString()=="Label"?"": "tk"%> "></span> <%#Eval("typesname")%>
    </span>
    </td>

                  <td>
                      <%#Eval("subject")%>
                  </td>

                  <td > 
    <span class="questpoints">
        <%#Eval("types").ToString()=="Label"?" ": Eval("points")+" 分"%>   
    </span>
    </td>

                     <td>
             <a href="###"  onclick='del(this,<%#Eval("autoid") %>)' class="layui-btn layui-btn-danger layui-btn-xs">移除</a>
          </td>

                      </tr>
        </ItemTemplate>


    </asp:Repeater>

   
    </table>
   



       <asp:SqlDataSource ID="SqlDataSource1" runat="server"    
     OldValuesParameterFormatString="old_{0}"  
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    
        DeleteCommand="DELETE FROM [Survery_subjects] WHERE [autoid] = @old_autoid; delete from survery_options where id=@old_id and activeid=@activeid " 
         
        SelectCommand="SELECT * FROM [survery_subjects] where activeid=@activeid    " 
        
        UpdateCommand="  
        if(not exists( select * from Survery_subjects where id=@id and  activeid=@activeid)) 
        begin
             update [Survery_subjects] SET answer=@answer, [subject] = @subject, typesname=@typesname,  
             [types] = @types, [id] = @id, col=@col,
             points=@points  WHERE [autoid] = @old_autoid
             end
         else
         begin

          update [Survery_subjects] SET answer=@answer, [subject] = @subject, typesname=@typesname,  
        [types] = @types,  col=@col,
    points=@points WHERE [autoid] = @old_autoid 
         end
         
         update survery_options set id=@id where id=@old_id and activeid=@activeid 
          " 
         
         >
        
        <DeleteParameters>
           <asp:QueryStringParameter Name="activeid" Type="Int32" QueryStringField="activeid" />
        </DeleteParameters>
        
         <SelectParameters>
          <asp:QueryStringParameter Name="activeid" Type="Int32" QueryStringField="activeid" />
        </SelectParameters>
       
       
        <UpdateParameters>
            <asp:Parameter Name="subject" Type="String" />
            <asp:Parameter Name="types" Type="String" />
             <asp:Parameter Name="typesname" Type="String" />
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="old_autoid" Type="Int32" />
            <asp:Parameter Name="points" Type="Int32" /> 
             <asp:QueryStringParameter Name="activeid" Type="Int32" QueryStringField="activeid" />
        </UpdateParameters>
      
    
    </asp:SqlDataSource>

    






    <script>

        function del(obj,autoid)
        {
            var isdel = confirm("确定删除吗？");

            if (isdel)
            {
                $(obj).parent().parent().remove();
                 $.get("ajax/del_subject.aspx?autoid=" + autoid);
                setIdx();

            }

        }

    </script>



      <script>
          function setIdx()
          {
              var _idx = 0;
              $(".idx").filter(".tk").each(function () {
                  _idx = _idx + 1;

                  $(this).html(_idx + ".");

              });
          }
          setIdx();
    </script>



    </div>
</asp:Content>
