<%
__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 tbUser order by UID");
  
if (op=="del")
  iupd=db_UpdAdv("delete from tbUser where UID="+type);
  

if (op=="ins"){
  if (db_QryInt("select count(*) from tbUser where Code='"+code+"' or Name='"+name+"'",1)>0)
    write(serr);
  else
    iupd=db_UpdAdv("insert into tbUser(Code,Name,State,Kind,Recv,Note,SmsNum,TelNum,Email) values('"+code+"','"+name+"',"+state+","+kind+","+recv1+",'"+note+"','"+smsnum+"','"+telnum+"','"+email+"')",1);
	
}


 if (op=="upd")
  iupd=db_UpdAdv("update tbUser set Code='"+code+"',Name='"+name+"',State="+state+",Kind="+kind+",Recv="+recv1+",Note='"+note+"',SmsNum='"+smsnum+"',TelNum='"+telnum+"',Email='"+email+"'where UID="+uid,1);

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