<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#A2C6CE, #E8F1B7]" themeColor="#BCD4E3" creationComplete="init()">
<mx:Script>
	<![CDATA[
		import mx.controls.Button;
		import mx.controls.Alert;
		import mx.collections.XMLListCollection;
		import mx.rpc.events.FaultEvent;
		import mx.rpc.events.ResultEvent;
		
		[Bindable]
		private var re:String=new String;
		public var querydata:XMLListCollection;
		public function init():void
		{
			HolidayTripWebService.getcountry();
		}
		public function getcon(event:ResultEvent):void
		{
			//if(event.result!=" ")
			//{
			var query:XML=new XML(event.result);
			//var querydata:XMLListCollection = new XMLListCollection(query.Table);
			querydata = new XMLListCollection(query.Country);
			con1.dataProvider = querydata;
			con1.labelField="CountryName";
			con1.data="CountryID";
			
			
		}
		public function fault(event:FaultEvent):void
		{
		}
		
		public function InsertCityre(event:ResultEvent):void
		{	
			Alert.show("event");
	re=event.result.toString();
	if(re.length==4)
	Alert.show("Inserted");	
	else
	Alert.show("Not Inserted");
		}
	public function InsertCity1():void
		{	
			re = HolidayTripWebService.InsertCity(parseInt( con1.selectedItem.CountryID.toString()),CityName.text,Desc.text);	
		}
		
		public function Home():void
		{
			var url:URLRequest=new URLRequest("AdminHome.html");
			navigateToURL(url,"_self");
		}
		
		public function Logout():void
		{
			var url:URLRequest=new URLRequest("Login.html");
			navigateToURL(url,"_self");
		}
		
		
	]]>
</mx:Script>

	<mx:WebService
		id="HolidayTripWebService" 
		wsdl="http://localhost:50854/HTWS/Service.asmx?wsdl"
		showBusyCursor="true" fault="mx.controls.Alert.show('Error loading WSDL', 'Webservice Error');" >
		<mx:operation name="getcountry" resultFormat="object" result="getcon(event)">
        </mx:operation>
        <mx:operation name="InsertCity" resultFormat="object" result="InsertCityre(event)">
        </mx:operation>
        		
	</mx:WebService>
	
	
	<mx:Label x="297" y="66" text="Add City" fontFamily="Courier New" fontSize="25" fontWeight="bold" fontStyle="normal" color="#823824"/>
	<mx:Text x="199" y="142" text="Select Country:" fontSize="13" fontWeight="bold"/>
		<mx:Text x="245" y="203" text="City Name:" fontSize="13" fontWeight="bold" id="lCityName"/>
		<mx:TextInput x="379" y="204" id="CityName"/>
		<mx:Text x="245" y="249" text="Description:" fontSize="13" fontWeight="bold" id="lDesc"/>
		<mx:TextInput x="379" y="250" id="Desc"/>
		<mx:ComboBox id="con1" width="150" x="379" y="143" >        
    </mx:ComboBox>
<mx:Button x="311" y="282" label="Submit" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" width="67" height="28" cornerRadius="20" click="InsertCity1()"/>
	<mx:Button x="768" y="50" label="Home" width="61" height="23" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" cornerRadius="20" click="Home()"/>
	<mx:Button x="898" y="50" label="Logout" width="75" height="23" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" cornerRadius="20" click="Logout()"/>
	
	


</mx:Application>
