<%
__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 tbUser");
if (op=="del")
  iupd=db_UpdAdv("delete from tbUser where UID="+uid);
if (op=="ins")
{
  sql = "insert into tbUser(Code,Name,Note,State,Kind,Recv,SmsNum,TelNum,Email)";
  sql = sql+" values('"+code+"','"+name+"','"+note+"',"+state+","+kind+","+recv+",'"+smsnum+"','"+telnum+"','"+email+"')";
  iupd=db_UpdAdv(sql,1);
}
if (op=="upd")
{
  sql = "update tbUser set Code='"+code+"',Name='"+name+"',Note='"+note+"',State="+state+",Kind="+kind;
  sql = sql+",Recv="+recv+",SmsNum='"+smsnum+"',TelNum='"+telnum+"',Email='"+email+"' where UID="+uid;
  iupd=db_UpdAdv(sql,1);
}

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