Sie sind auf Seite 1von 2

<?xml version="1.0" encoding="utf-8"?

>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/
spark"
xmlns:mx="library://ns.adobe.com/flex
/mx" width="1024" height="600" backgroundColor="#717171"
creationComplete="onCreationComplete(
)" currentState="Home">
<s:states>
<s:State name="Home"/>
<s:State name="New"/>
<s:State name="Sites"/>
</s:states>
<fx:Script>
<![CDATA[
private var connection:SQLConnection;
private function onCreationComplete():void
{
var dbFile:File = File.applicationStorageDirecto
ry.resolvePath("NetworkSites.db");
connection = new SQLConnection();
connection.open ( dbFile );
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "CREATE TABLE IF NOT EXISTS SIT
ES (SITE_ID INTEGER PRIMARY KEY AUTOINCREMENT, SITENAME TEXT, ACCOUNTNUMBER TEXT
, EXTERNALIP TEXT)"
statement.execute();
}
private function refreshNetworkSites():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "SELECT * FROM SITES";
statement.execute();
SiteGrid.dataProvider = statement.getResult().da
ta;
}
private function addSite():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "INSERT INTO SITES (SITENAME, A
CCOUNTNUMBER, EXTERNALIP) VALUES (?, ?, ?)";
statement.parameters[0] = SiteName.text;
statement.parameters[1] = AccountNumber.text;
statement.parameters[2] = ExternalIP.text;
statement.execute();
refreshNetworkSites();
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:TextInput id="SiteName" text="Site Name" width="200" x="10" y
="10" height="50" fontSize="18" fontWeight="bold" includeIn="New"/>
<s:TextInput id="AccountNumber" text="Account Number" width="200
" x="218" y="40" includeIn="New"/>
<s:TextInput x="10" y="147" id="ExternalIP" height="36" fontSize
="22" text="External IP" fontWeight="normal" fontFamily="Arial" width="184" incl
udeIn="New"/>
<s:Button x="800" y="10" label="Save" width="103" height="52" id
="Save" fontSize="28" fontWeight="bold" includeIn="New" click="addSite()" />
<s:Button x="911" y="10" label="Home" width="103" height="52" id
="Home" fontSize="28" fontWeight="bold" includeIn="New,Sites" click="currentStat
e = currentState=='Home' ? '':'Home';" />
<s:Button includeIn="Home" x="99" y="164" label="New Site" width
="199" height="87" id="New" fontSize="36" click="currentState = currentState=='N
ew' ? '':'New';" />
<s:Button includeIn="Home" x="312" y="164" label="View Sites" wi
dth="199" height="87" id="SitesBTN" fontSize="36" click="currentState = currentS
tate=='Sites' ? '':'Sites';" />
<mx:DataGrid includeIn="Sites" x="9" y="64" width="1004" height=
"512" id="SiteGrid">
<mx:columns>
<mx:DataGridColumn headerText="S
ite Name" dataField="SiteName"/>
<mx:DataGridColumn headerText="A
ccount Number" dataField="AccountNumber"/>
<mx:DataGridColumn headerText="E
xternal IP" dataField="ExternalIP"/>
</mx:columns>
</mx:DataGrid>
</s:WindowedApplication>

Das könnte Ihnen auch gefallen