//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=$482; this.makeButtons=$499; this.readTable=$490; this.readGraphicTable=$491; this.getX=$479X; this.getY=$479Y; this.getHref=$479Href; this.newRecord=$480; this.newPointRecord=$481; this.resolve=$495; this.deleteRecord=$496; this.deleteRecordAll=$496All; this.deleteRecord_A=$496_A; this.isImg=$500; this.execute=$492; this.saveRecord=$494; this.saveTable=$493; this.first=$486; this.last=$489; this.next=$488; this.prev=$487; this.put=$478; this.get=$479; } function $478(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 $479(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 $480() { if(this.rs.status==0)return 0; this.saveRecord(); this.rs.AddNew(); this.makeElements(); return this.rs.RecordCount; } function $481(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 $482() { 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=""; } for(i=0; i =0) { v=v.replace("'"," "); } while(v.indexOf("\"")>=0) { v=v.replace("\""," "); } n=this.rs.Fields(i).name; if(def) { xname=n.toUpperCase(); if(xname=="X")continue; if(xname=="Y")continue; if(xname=="ID")continue; if(xname=="XMIN")continue; if(xname=="YMIN")continue; if(xname=="XMAX")continue; if(xname=="YMAX")continue; add=""; if(xname=='HREF'&&(!((v==null)||(v==""))))add=" "; more=" id=\"DB_"+xname+"\""; more=more+" onMouseDown=\"DBUpdate('"+this.id+"')\""; text=text+""+ ""; } else { text=text+this.onFormatField(this.rs.Fields(i),n,v,i+1,this.rs.Fields.Count); } } if(def)text=text+'
"+ ""+n+""+add+"
' 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 $479X() { var x; try { x=this.rs.Fields('x').value; } catch(e){ x=0} return x; } function $479Href() { var h; try { h=this.rs.Fields('Href').value; } catch(e){ h="" } return h; } function $479Y() { var y; try { y=this.rs.Fields('y').value; } catch(e){ y=0 } return y; } function $486(){ try { this.saveRecord(); this.rs.MoveFirst(); this.makeElements(); return true; } catch(e){ return false } } function $487(){ try { this.saveRecord(); this.rs.MovePrevious(); if(this.rs.BOF)this.rs.MoveFirst(); this.makeElements(); return true; } catch(e){ return false } } function $488(){ try { this.saveRecord(); this.rs.MoveNext(); if(this.rs.EOF)this.rs.MoveLast(); this.makeElements(); return true; } catch(e){ return false } } function $489(){ try { this.saveRecord(); this.rs.MoveLast(); this.makeElements(); return true; } catch(e){ return false } } function $490(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 $491(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 $492(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 $493() { 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 $494() { 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 $500(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; }