//ICMap, Copyright 2006, clifford L. Collins, Collins Software, all rights reserved, http://collinssoftware.com, not for distribution or resale, use License is required: icdatabase
function passed(A)
{
if((A==null)||(A==undefined))return false;
return true;
}
function ic$Database(id,receiver,database,table,column,Q,dataElement,countElement,navButtons,imgElement,onFormatField,onShowTable,onFail)
{
this.id=id;
this.database=database;
this.data=null;
this.count=null;
this.navButtons=null;
this.img=null;
if(passed(dataElement))this.data=dataElement;
if(passed(countElement))this.count=countElement;
if(passed(navButtons))this.navButtons=navButtons
if(passed(imgElement))this.img=imgElement;
this.onFormatField=onFormatField;
this.onShowTable=onShowTable;
this.onFail=onFail;
this.isRecordModified=false;
this.isTableModified=false;
this.tableName=table;
this.columnName=column;
this.Q=Q;
this.receiver=receiver+"?database="+this.database+'&';
this.makeElements=$490;
this.makeButtons=$507;
this.readTable=$498;
this.readGraphicTable=$499;
this.getX=$487X;
this.getY=$487Y;
this.getHref=$487Href;
this.newRecord=$488;
this.newPointRecord=$489;
this.resolve=$503;
this.deleteRecord=$504;
this.deleteRecordAll=$504All;
this.deleteRecord_A=$504_A;
this.isImg=$508;
this.execute=$500;
this.saveRecord=$502;
this.saveTable=$501;
this.first=$494;
this.last=$497;
this.next=$496;
this.prev=$495;
this.put=$486;
this.get=$487;
}
function $486(name,value)
{
if(this.rs.status==0)return false;
try
{
f=this.rs.Fields.Item(name);
f.value=value;
return true;
}
catch(e){ return false }
}
function $487(name)
{
var f,value;
if(this.rs.status==0)return"";
try
{
f=this.rs.Fields.Item(name);
value=f.value;
if(value==null)value="";
if(value.length >1000)value=value.substr(1,400);
return value;
}
catch(e){ return"" }
}
function $488()
{
if(this.rs.status==0)return 0;
this.saveRecord();
this.rs.AddNew();
this.makeElements();
return this.rs.RecordCount;
}
function $489(x,y,href)
{
if(this.rs.status==0)return 0;
this.saveRecord();
this.rs.AddNew();
this.put("xmin",x);
this.put("ymin",y);
this.put("xmax",x);
this.put("ymax",y);
this.put("x",x);
this.put("y",y);
this.put("href",href);
this.makeElements();
return this.rs.RecordCount;
}
function $490()
{
var text;
var v,n,xname;
var i,add;
text="";
if(this.data !=null)this.data.innerHTML=text;
if(this.count !=null)this.count.innerText=""
this.isRecordModified=false;
if((! this.rs)||(this.rs.BOF&& this.rs.EOF))
{
if(this.onFail !=null)text=this.onFail();
if(this.data !=null)this.data.innerHTML=text;
return false;
}
def=true;
if(this.onFormatField !=null)def=false;
if(def){ text="
'
if(this.onShowTable !=null)
{ this.onShowTable(text)}
else{ if(this.data !=null)this.data.innerHTML=text;}
if(this.count==null)return;
if( this.rs.RecordCount >0)
if(this.count !=null)this.count.innerText=this.rs.AbsolutePosition+' of '+this.rs.RecordCount;
}
function $487X()
{
var x;
try
{
x=this.rs.Fields('x').value;
}
catch(e){ x=0}
return x;
}
function $487Href()
{
var h;
try
{
h=this.rs.Fields('Href').value;
}
catch(e){ h="" }
return h;
}
function $487Y()
{
var y;
try
{
y=this.rs.Fields('y').value;
}
catch(e){ y=0 }
return y;
}
function $494(){
try
{
this.saveRecord();
this.rs.MoveFirst();
this.makeElements();
return true;
}
catch(e){ return false }
}
function $495(){
try
{
this.saveRecord();
this.rs.MovePrevious();
if(this.rs.BOF)this.rs.MoveFirst();
this.makeElements();
return true;
}
catch(e){ return false }
}
function $496(){
try
{
this.saveRecord();
this.rs.MoveNext();
if(this.rs.EOF)this.rs.MoveLast();
this.makeElements();
return true;
}
catch(e){ return false }
}
function $497(){
try
{
this.saveRecord();
this.rs.MoveLast();
this.makeElements();
return true;
}
catch(e){ return false }
}
function $498(tableName){
var text;
this.isModified=false;
try
{
this.table=tableName;
this.rs=new ActiveXObject("ADODB.Recordset");
this.xmlDoc=new ActiveXObject("MsDB2.DOMDocument");
this.xmlhttp=new ActiveXObject("MsDB2.XMLhttp");
text=this.receiver+"getRecordset=YES&Table="+tableName;
this.xmlhttp.Open("Get",text,false);
this.xmlhttp.send();
this.xmlDoc.loadXML(this.xmlhttp.responseText);
this.rs.Open(this.xmlDoc);
if(this.navButtons !=null)this.navButtons.style.display='';
this.makeElements();
return true;
}
catch(e){ window.alert(e.description); return false }
}
function $499(tableName,xmin,ymin,xmax,ymax){
var text;
this.isModified=false;
try
{
this.table=tableName;
this.rs=new ActiveXObject("ADODB.Recordset");
this.xmlDoc=new ActiveXObject("MsDB2.DOMDocument");
this.xmlhttp=new ActiveXObject("MsDB2.xmlhttp");
text=this.receiver+"getRecordset=YES&Table="+tableName+
"&Graphic=YES"+
"&xmin="+xmin+"&ymin="+ymin+
"&xmax="+xmax+"&ymax="+ymax;
this.xmlhttp.Open("Get",text,false);
this.xmlhttp.send();
this.xmlDoc.loadXML(this.xmlhttp.responseText);
this.rs.Open(this.xmlDoc);
if(this.navButton !=null)this.navButtons.style.display='';
this.makeElements();
return true;
}
catch(e){ window.alert(e.description); return false }
}
function $500(sql){
var text;
if(this.rs)
{
if(!(this.rs.BOF&& this.rs.EOF))
{
if(this.rs.status !=0)this.rs.close();
}
}
this.isModified=false;
try
{
this.table="";
this.rs=new ActiveXObject("ADODB.Recordset");
this.xmlDoc=new ActiveXObject("MsXml2.DOMDocument");
this.xmlhttp=new ActiveXObject("MsXml2.xmlhttp");
text=this.receiver+"getRecordset=YES&SQL="+sql;
this.xmlhttp.Open("Get",text,false);
this.xmlhttp.send();
strToFile(this.xmlhttp.responseText,'c:/xx.htm');
this.xmlDoc.loadXML(this.xmlhttp.responseText);
this.rs.Open(this.xmlDoc);
if(this.navButtons !=null)this.navButtons.style.display='';
this.makeElements();
return true;
}
catch(e){ window.alert(e.description); return false }
}
function $501()
{
var text;
if(! this.isTableModified)return;
if(this.rs.status==0)return;
try
{
var DBstream=new ActiveXObject("ADODB.Stream");
DBstream.Mode=3;
DBstream.Open();
DBstream.Type=1;
this.rs.Save(DBstream,0);
this.xmlhttp=new ActiveXObject("Msxml2.xmlhttp");
this.xmlhttp.Open("POST",this.receiver+"getRecordset=NO",false);
this.xmlhttp.setRequestHeader("Content-Length",DBstream.Size);
this.xmlhttp.send(DBstream.Read(DBstream.Size));
alert(this.xmlhttp.responseText);
return true;
}
catch(e){ window.alert(e.description); return false }
}
function $502()
{
if(this.rs.status==0)return;
if(this.rs.RecordCount <=0)return;
if(! this.isRecordModified)return;
this.lastMsg="";
try
{
for(i=0; i ";
t=t+"";
t=t+"\" STYLE=\"width:20px\" onclick=\""+this.id+".next()\">";
t=t+">\" onclick=\""+this.id+".last()\">";
t=t+" ";
t=t+"";
t=t+"";
t=t+"";
this.navButtons.innerHTML=t;
this.navButtons.style.display='none';
}
function $508(f)
{
var b,ms,o,c;
if(f.name.toUpperCase()!="PICTURE")return false;
if(this.img==null)return true;
if(f.value==null)return true;
try
{
tr=this.rs.GetString(2);
size=f.ActualSize;
this.img.src=tr
}
catch(e){window.alert(e.description)}
return true;
}