<%
__header("Content-Type","text/html; charset=gb2312");
var serr="{\"op\":\"op err\"}";
if (op=="")
  write(serr);
else
{
var iupd=-1;
db_Open("/NandFlash/dbCfg.db3");
if (op=="qry")
  db_QryAdv("select * from tbSMKind order by Kind");
if (op=="del")
  iupd=db_UpdAdv("delete from tbSMKind where Kind="+kind);
if (op=="ins")
  iupd=db_UpdAdv("insert into tbSMKind values("+kind+",'"+name+"','"+note+"')",1);
if (op=="upd") // kind0?
  iupd=db_UpdAdv("update tbSMKind set Name='"+name+"',Note='"+note+"' where Kind="+kind,1);

if (iupd<0 && iupd!=-1)
  write(serr);
if (iupd>=0)
{
  var lastId = db_QryLastRowId();
  write("{\"op\":\"ok\",\"kid\":"+lastId+"}");
}
db_Close();
}
%>