<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="GB2312">
    <title></title>
    <link href="css/style.css" title="style" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.6.3.min.js"></script>

</head>
<body style="background: #F3F3F3">
<div>
  <div class='list2' style='margin: 10px;'>
    <a class='you_p' href='#' style='color: #fff'>传感器型号管理</a>
  </div>
  <div style='border: #B0B7BF 1px solid'>
    <table id='tbTypes' width='100%'>
    <tr bgcolor='#E5E9EC'><th><span>类别型号</span></th><th>说明</th><th>接口类型</th><th>编号<th>操作</th></tr>
    </table>
  </div>
</div>
<div class='list2' style='margin: 10px;'>
  <table width='100%'><tr>
    <th><a href='C0-9x.asp?type=0&tag1=0' class='back' style='color: #fff;background: #ffa225'>增加</a></th>
    <th><a href='javascript:history.back()' class='back' style='color: #fff'>返回</a></th>
  </tr></table>
</div>

<script>
var imode=0;

<% db_Open("/NandFlash/dbCfg.db3"); %>
var jtypes=<% db_QryAdv("select Type,t.Kind,t.Name,t.Note,Tag1,Port,k.Name as KName from tbSMType t left join tbSMKind k on k.Kind=t.Kind order by Type,Tag1",0); %>;
<% db_Close(); %>

$(function(){
    listTypes();
    alert("ssss");
});

function listTypes(){
  if (jtypes.reccnt==0){
    return;
  }
  var stbl="<tr bgcolor='#E5E9EC'><th><span>类别型号</span></th><th>说明</th><th>接口类型</th><th>编号<th>操作</th></tr>";
  $.each(jtypes.recs,function(i,n){
    if(n.Tag1=="") n.Tag1=0;
    stbl+="<tr id='tr"+i+"'><th style='text-align: left'>"+n.KName+" ("+n.Name+")</th><th style='text-align: left'>"+n.Note+"</th><th>"+getPort(n.Port)+"</th><th>"+n.Type+"-"+n.Tag1+"</th><th>"+getOps(n, i)+"</th><tr>";
  })
  $("#tbTypes").html(stbl);
}

function getPort(iport){
  var s="";
  switch(iport){
  case 1: s="DI";break;
  case 2: s="DO";break;
  case 3: s="232";break;
  case 4: s="485";break;
  case 5: s="232/485";break;
  case 6: s="NET";break;
  }
  return s;
}
function getOps(n, i){
  var s="<a href='C0-9x.asp?type="+n.Type+"&tag1="+n.Tag1+"'>编辑</a>&nbsp;&nbsp;"+"<a href='javascript:delType("+n.Type+","+n.Tag1+","+i+")'>删除</a>";
  return s;
}
function delType(itype, itag, itr){
  var s="确定要删除 "+$("#tr"+itr+" th:eq(0)").text()+" 编号"+itype+"-"+itag+" 吗?";
  if(!confirm(s)) return;
  $.ajax({
    type: "POST",
    url: "omdev/smtype.asp",
    data: "op=del2&type="+itype+"&tag1="+itag,
    dataType:"json",
    success: function(msg){
      if(msg.op=="ok")
        $("#tr"+itr).remove();
      else
        alert("删除 "+$("#tr"+itr+" th:eq(0)").text()+" 编号"+itype+"-"+itag+" 失败!");
    }
  });
}
</script>
</body>
</html>