<%
__header("Content-Type","text/html; charset=gb2312");
var serr="{\"op\":\"op err\"}";
if (op=="")
  write(serr);
else
{
var sql;
var iupd=-1;
db_Open("/NandFlash/dbCfg.db3");
if (op=="qry")
  db_QryAdv("select * from tbAlmTime");
if (op=="qryby")
  db_QryAdv("select * from tbAlmTime where TID="+tid);
if (op=="del")
  iupd=db_UpdAdv("delete from tbAlmTime where TID="+tid);
if (op=="ins")
{
  sql = "insert into tbAlmTime(Note,Start0,End0,Start1,End1,Start2,End2,Start3,End3,Start4,End4,Start5,End5,Start6,End6)";
  sql = sql+" values('"+note+"',"+start0+","+end0+","+start1+","+end1+","+start2+","+end2+","+start3+","+end3;
  sql = sql+","+start4+","+end4+","+start5+","+end5+","+start6+","+end6+")";
  iupd=db_UpdAdv(sql,1);
}
if (op=="upd")
{
  sql = "update tbAlmTime set Note='"+note+"',Start0="+start0+",End0="+end0+",Start1="+start1+",End1="+end1;
  sql = sql+",Start2="+start2+",End2="+end2+",Start3="+start3+",End3="+end3+",Start4="+start4+",End4="+end4;
  sql = sql+",Start5="+start5+",End5="+end5+",Start6="+start6+",End6="+end6+" where TID="+tid;
  iupd=db_UpdAdv(sql,1);
}

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