44 lines
1.4 KiB
ActionScript
44 lines
1.4 KiB
ActionScript
import mx.rpc.events.ResultEvent;
|
|
import mx.collections.XMLListCollection;
|
|
|
|
private var params:Object = new Object();
|
|
[Bindable]
|
|
private var listData:XMLListCollection;
|
|
|
|
public function resultHandler(event:ResultEvent):void {
|
|
var result:XML = XML(event.result);
|
|
var xmlList:XMLList = result.data.children();
|
|
listData = new XMLListCollection(xmlList);
|
|
}
|
|
|
|
public function insertItemHandler(event:ResultEvent):void {
|
|
fill();
|
|
}
|
|
|
|
public function fill():void{
|
|
employeesService.removeEventListener(ResultEvent.RESULT,insertItemHandler);
|
|
employeesService.addEventListener(ResultEvent.RESULT,resultHandler);
|
|
employeesService.method = "GET";
|
|
params['method'] = "FindAllEmployees";
|
|
employeesService.cancel();
|
|
employeesService.send(params);
|
|
viewstack1.selectedIndex=1;
|
|
}
|
|
|
|
public function insertEmployee():void{
|
|
employeesService.removeEventListener(ResultEvent.RESULT,resultHandler);
|
|
employeesService.addEventListener(ResultEvent.RESULT,insertItemHandler);
|
|
employeesService.method = "POST";
|
|
params = {"method": "InsertEmployee", "id": NaN, "firstName": inputFirst.text,
|
|
"lastName": inputLast.text, "officePhone": inputPhone.text};
|
|
employeesService.cancel();
|
|
employeesService.send(params);
|
|
clearInputFields();
|
|
}
|
|
|
|
private function clearInputFields():void{
|
|
inputFirst.text = "";
|
|
inputLast.text = "";
|
|
inputPhone.text = "";
|
|
}
|