flex 多级窗口互调连接oracle动态管理生成动态datagrid

废话不多说,直接上代码讲解: 
首先是对datagrid的管理界面 ,里面有增加,删除,修改,界面如下: 

flex 多级窗口互调连接oracle动态管理生成动态datagrid_第1张图片  

然后主页面名字 :EditeBusPdGo.xml,代码如下: 
Java代码 
  1. "1.0" encoding="utf-8"?>  
  2. "http://ns.adobe.com/mxml/2009"   
  3.                xmlns:s="library://ns.adobe.com/flex/spark"   
  4.                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">  
  5.       
  6.           
  7.           
  8.       
  9.       
  10.       
  11.         
  12.             import mx.collections.ArrayCollection;  
  13.             import mx.collections.ArrayList;  
  14.             import mx.controls.Alert;  
  15.             import mx.controls.DataGrid;  
  16.             import mx.controls.dataGridClasses.DataGridColumn;  
  17.             import mx.events.CloseEvent;  
  18.             import mx.events.ListEvent;  
  19.             import mx.formatters.DateFormatter;  
  20.             import mx.managers.PopUpManager;  
  21.             import mx.rpc.events.ResultEvent;  
  22.             import mx.rpc.soap.WebService;  
  23.               
  24.             public var dgDataArr:Array;  
  25.             private static var dateFormatter:DateFormatter = new DateFormatter();  
  26.         //  private var formatString:String="YYYY-MM-DD";  
  27.             [Bindable]    
  28.             private var notes:ArrayCollection ;    
  29.               
  30.               
  31.             private var addNoteScreen:AddBusLineRunTime;   
  32.             private var UpdateNoteScreen:UpdateBusLineRunTm;  
  33.               
  34.             private var WebServiceUrl:String="http://localhost:10635/AnalysisRdBl/AnalysisBL.asmx?wsdl";  
  35.               
  36.               
  37.             private var setBusName:String="99路";  
  38.               
  39.             private var setTime:String="2012-12-02";  
  40.               
  41.             private function init():void{  
  42.                 runTimeTable.text=setBusName+"行车计划时刻表";  
  43.                 doTime.text="实施日期:  "+setTime;  
  44.                 getdata();  
  45.                   
  46.                 addNoteScreen = new AddBusLineRunTime();    
  47.                 addNoteScreen.addEventListener("SaveNote", saveNote);   
  48.                   
  49.                 UpdateNoteScreen=new UpdateBusLineRunTm();  
  50.                 UpdateNoteScreen.addEventListener("SaveNote",update);  
  51.             }  
  52.             private function update(e:Event):void  
  53.             {  
  54.                   
  55.                 var ob:Object=new Object();  
  56.                   
  57.                   
  58.                   
  59.                 ob.线路名=setBusName;  
  60.                 ob.路牌名=UpdateNoteScreen.lupai.text;  
  61.                 ob.圈=UpdateNoteScreen.quan.text;  
  62.                 ob.实施时间=setTime;  
  63.                 ob.报到=UpdateNoteScreen.baodao.text;  
  64.                 ob.工时=UpdateNoteScreen.gongshi.text;  
  65.                 ob.出场=UpdateNoteScreen.chuchang.text;  
  66.                 ob.离场=UpdateNoteScreen.lichang.text;  
  67.                   
  68.                 var updatenotes:ArrayCollection= new ArrayCollection();  
  69.                 updatenotes.addItem(ob);  
  70.                   
  71.                   
  72.                 var temparr:ArrayCollection=new ArrayCollection();  
  73.                 temparr=UpdateNoteScreen.notes;  
  74.                   
  75.                 var xx:XML=TWOarrToXml(updatenotes,temparr);  
  76.                 var xxString:String=xx.toXMLString();  
  77.                 //trace(xx.toXMLString());  
  78.                   
  79.                 var ws1:WebService = new WebService();  
  80.                 ws1.loadWSDL(WebServiceUrl);  
  81.                   
  82.                 ws1.updateTable.addEventListener(ResultEvent.RESULT, resultUpdateData);  
  83.                   
  84.                 ws1.updateTable.send(updateO,xxString);  
  85.                 PopUpManager.removePopUp(UpdateNoteScreen);  
  86.                   
  87.               
  88.             }  
  89.               
  90.             private function resultUpdateData(e:ResultEvent):void  
  91.             {  
  92.                 getdata();  
  93.                 if(e.result as String=="success")  
  94.                 {  
  95.                 Alert.show("更新成功!");  
  96.                 }  
  97.                 else  
  98.                 {  
  99.                 Alert.show("更新失败!");  
  100.                 }  
  101.             }  
  102.             private function getdata():void  
  103.             {  
  104.                 var ws1:WebService = new WebService();  
  105.                 ws1.loadWSDL(WebServiceUrl);  
  106.                   
  107.                 ws1.GetBusRunTimeList.addEventListener(ResultEvent.RESULT, resultGetData);  
  108.                   
  109.                 ws1.GetBusRunTimeList.send(setBusName,setTime);  
  110.             }  
  111.               
  112.             public var ObObArr:Array;  
  113.               
  114.             private function refreshObOb():void  
  115.             {  
  116.                 ObObArr=new Array();  
  117.                 for(var i:int=0;i
  118.                 {  
  119.                     var LuLU:String=dgDataArr[i]["路牌名"].toString();  
  120.                   
  121.                     ObObArr.push(LuLU);  
  122.                       
  123.                       
  124.                 }  
  125.             }  
  126.               
  127.             private function resultGetData(e:ResultEvent):void{  
  128.                 if(e.result as String=="noData")  
  129.                 {  
  130.                 Alert.show("您好,本线路下面还没有具体线路信息,请添加","没有信息!")  
  131.                 }  
  132.                 else{  
  133.                 var returnValue:XMLList=XML(e.result).children();  
  134.                 //ShowRunTimeTable.dataProvider=xmlListToArray(returnValue);  
  135.                 dgDataArr=new Array();   
  136.                 dgDataArr=xmlListToArray(returnValue);  
  137.                   
  138.                   
  139.                 refreshObOb();  
  140. //              for(var i:int=0;i  
  141. //              {  
  142. //                  var LuLU:String=dgDataArr[i]["路牌名"].toString();  
  143. //                  trace(LuLU);  
  144. //                  ObObArr.push(LuLU);  
  145. //                    
  146. //                
  147. //              }  
  148.                 //deleteArr=xmlListToArray(returnValue);  
  149.                 showTableInit();  
  150.                 }  
  151.                   
  152.             }  
  153.               
  154.             private function xmlListToArray(results:XMLList):Array     
  155.             {     
  156.                 var array:Array=new Array();     
  157.                 for each(var child:XML in results)     
  158.                 {     
  159.                     var obj:Object=new Object();     
  160.                     //obj[child.nodeKind()]=child[child.nodeKind()];     
  161.                     for each(var ite:XML in child.children())     
  162.                     {     
  163.                         obj[ite.name().toString()]=child[ite.name().toString()];     
  164.                     }     
  165.                       
  166.                     //array.addItem(obj);  
  167.                     array.push(obj);  
  168.                 }     
  169.                 return array;     
  170.             }    
  171.               
  172.             private function getArraylistFromXMLList(data:XMLList):Array  
  173.             {  
  174.                 var al:Array=new Array();  
  175.                 for(var i:int=0;i
  176.                 {   
  177.                     var obj:Object=new Object();  
  178.                     for(var j:int=0;j
  179.                     {  
  180.                         var dataColoum:String=data[i].children()[j].localName();  
  181.                         obj[dataColoum]=data[i].children()[j].toString();  
  182.                           
  183.                     }  
  184.                     al.addItem(obj);  
  185.                 }  
  186.                 return al;  
  187.             }  
  188.               
  189.               
  190.               
  191.             //public var deleteArr:Array=new Array();  
  192.             //public var xxfc:Function;  
  193.             private function showCol():Array  
  194.             {  
  195.                 var arr:Array=new Array();  
  196.                 var dataNum:int=dgDataArr[0]["站长"];  
  197.                 //trace(dataNum.toString());  
  198.                   
  199.               
  200.                 //trace(dgDataArr[0]["OBJECTID"]);  
  201.                 var shouzhan:String="首站";  
  202.                 var mozhan:String="末站";  
  203.                   
  204.                 for(var i:int=1;i<=dataNum;i++)  
  205.                 {  
  206.                     var temp1:String=shouzhan+i.toString();  
  207.                     var temp2:String=mozhan+i.toString();  
  208.                     arr.push(temp1);  
  209.                     arr.push(temp2);  
  210.                   
  211.                 }  
  212.                 return arr;  
  213.               
  214.                   
  215.             }  
  216.               
  217. //          private function upArray(ii:int):void  
  218. //          {  
  219. //              var dataNum:int=dgDataArr[ii]["此长"];  
  220. //              //trace(dataNum.toString());  
  221. //                
  222. //                
  223. //              //trace(dgDataArr[0]["OBJECTID"]);  
  224. //              var shouzhan:String="首站";  
  225. //              var mozhan:String="末站";  
  226. //                
  227. //              for(var i:int=1;i<=dataNum;i++)  
  228. //              {  
  229. //                  var temp1:String=shouzhan+i.toString();  
  230. //                  var temp2:String=mozhan+i.toString();  
  231. //                  arr.push(temp1);  
  232. //                  arr.push(temp2);  
  233. //                    
  234. //              }  
  235. //                
  236. //                
  237. //                
  238. //          }  
  239.               
  240.             //public var upArr:Array=new Array();  
  241.           
  242.             public var dataGrid:DataGrid;  
  243.             private var busNam:String="99路";  
  244.             private function showTableInit():void  
  245.             {  
  246.                   
  247.                 var dgData:ArrayCollection = new ArrayCollection(dgDataArr);   
  248.                  dataGrid = new DataGrid();   
  249.                  dataGrid.horizontalScrollPolicy = "on";  
  250.                 dataGrid.x = 10;   
  251.                 dataGrid.y = 20;   
  252.                 //dataGrid.editable = true;   
  253.                 dataGrid.percentWidth = 100;   
  254.                 dataGrid.percentHeight=90;  
  255.                 dataGrid.setStyle("fontSize"14);   
  256.                 dataGrid.styleName   
  257.                 dataGrid.dataProvider = dgData;   
  258.                 //dataGrid.addEventListener(ListEvent.ITEM_CLICK, itemClickHandler);   
  259.                 showDT.removeAllElements();  
  260.                 showDT.addElement(dataGrid);  
  261.                   
  262.                   
  263.                   
  264.                   
  265.                 var columns:Array = new Array();   
  266.                 var col:DataGridColumn;  
  267.               
  268.                   
  269.                 var buslineName1:String=dgDataArr[0]["线路名"];  
  270.                 //busNam=buslineName1;  
  271.                 var time:String=dgDataArr[0]["实施时间"];  
  272.                   
  273.                   
  274.                   
  275.                   
  276.                 var lupaicol:DataGridColumn=new DataGridColumn();  
  277.                 lupaicol.headerText="路牌";  
  278.                 lupaicol.dataField="路牌名";  
  279.                 columns.push(lupaicol);  
  280.                   
  281.                 var baodaocol:DataGridColumn=new DataGridColumn();  
  282.                 baodaocol.headerText="报到";  
  283.                 baodaocol.dataField="报到";  
  284.                 columns.push(baodaocol);  
  285.                   
  286.                 var chuchangcol:DataGridColumn=new DataGridColumn();  
  287.                 chuchangcol.headerText="出场";  
  288.                 chuchangcol.dataField="出场";  
  289.                 columns.push(chuchangcol);  
  290.                   
  291.                   
  292.                   
  293.             var arr:Array= showCol();  
  294.                 for(var i:int=1;i<=arr.length;i++)  
  295.                 {  
  296.                     var d:String=arr[i-1];  
  297.                     if(i%2==0)  
  298.                     {  
  299.                         col = new DataGridColumn(d);   
  300.                         col.headerText="末站";  
  301.                         columns.push(col);  
  302.                     }  
  303.                     else{  
  304.                         col = new DataGridColumn(d);   
  305.                         col.headerText="首站";  
  306.                         columns.push(col);  
  307.                     }  
  308.                       
  309.                 }  
  310.                 var lichangcol:DataGridColumn=new DataGridColumn();  
  311.                 lichangcol.headerText="离场";  
  312.                 lichangcol.dataField="离场";  
  313.                 columns.push(lichangcol);  
  314.                   
  315.                   
  316.                 var gongshicol:DataGridColumn=new DataGridColumn();  
  317.                 gongshicol.headerText="工时";  
  318.                 gongshicol.dataField="工时";  
  319.                 columns.push(gongshicol);  
  320.                   
  321.                   
  322.                 var quancol:DataGridColumn=new DataGridColumn();  
  323.                 quancol.headerText="圈";  
  324.                 quancol.dataField="圈";  
  325.                 columns.push(quancol);  
  326.   
  327.                 dataGrid.columns=columns;  
  328.                   
  329.             }  
  330.             private function itemClickHandler(e:ListEvent):void   
  331.             {   
  332.                 trace(e.target);   
  333.             }   
  334.               
  335.               
  336.               
  337.               
  338.               
  339.               
  340.             private function addNote():void    
  341.             {    
  342.                 PopUpManager.addPopUp(addNoteScreen, thistrue);    
  343.                 PopUpManager.centerPopUp(addNoteScreen);    
  344.                   
  345.                 addNoteScreen.ObObArr=ObObArr;  
  346.                 //addNoteScreen.author.text = "";    
  347.                   
  348.                 //addNoteScreen.topic.text = "";    
  349.                 //addNoteScreen.description.text = "";    
  350.             }    
  351.               
  352.             private function close():void    
  353.             {    
  354.                 PopUpManager.removePopUp(this);    
  355.             }    
  356.               
  357.             private function arrToXml(arr:ArrayCollection):XML{      
  358.                 var root:XML = new XML("");      
  359.                 for(var i:int = 0;i
  360.                     var node:XML = new XML("");      
  361.                      
  362.                       
  363.                     node.线路名=arr[i].线路名;  
  364.                     node.路牌名=arr[i].路牌名;  
  365.                     node.圈=arr[i].圈;  
  366.                     node.实施时间=arr[i].实施时间;  
  367.                     node.报到=arr[i].报到;  
  368.                     node.工时=arr[i].工时;  
  369.                     node.出场=arr[i].出场;  
  370.                     node.离场=arr[i].离场;  
  371.                           
  372.                           
  373.                     root.appendChild(node);      
  374.                 }      
  375.                 return root;      
  376.             }      
  377.               
  378.               
  379.             private function TWOarrToXml(arr:ArrayCollection,arr2:ArrayCollection):XML{      
  380.                 var root:XML = new XML("");      
  381.                 for(var i:int = 0;i
  382.                     var node:XML = new XML("");      
  383.                       
  384.                       
  385.                     node.线路名=arr[i].线路名;  
  386.                     node.路牌名=arr[i].路牌名;  
  387.                     node.圈=arr[i].圈;  
  388.                     node.实施时间=arr[i].实施时间;  
  389.                     node.报到=arr[i].报到;  
  390.                     node.工时=arr[i].工时;  
  391.                     node.出场=arr[i].出场;  
  392.                     node.离场=arr[i].离场;  
  393.                       
  394.                     for(var j:int=0;j
  395.                     {  
  396.                         var shou:String="首站"+(j+1);  
  397.                         var mo:String="末站"+(j+1);  
  398.                       node[shou]=arr2[j].首站;  
  399.                       node[mo]=arr2[j].末站;  
  400.                       
  401.                       
  402.                     }  
  403.                           
  404.                       
  405.                       
  406.                     root.appendChild(node);      
  407.                 }      
  408.                 return root;      
  409.             }   
  410.             public var xxString:String;  
  411.             private function saveNote(e:Event):void   
  412.             {   
  413.               
  414.                 var ob:Object=new Object();  
  415.   
  416.               
  417.                   
  418.                 ob.线路名=setBusName;  
  419.                 ob.路牌名=addNoteScreen.lupai.text;  
  420.                 ob.圈=addNoteScreen.quan.text;  
  421.                 ob.实施时间=setTime;  
  422.                 ob.报到=addNoteScreen.baodao.text;  
  423.                 ob.工时=addNoteScreen.gongshi.text;  
  424.                 ob.出场=addNoteScreen.chuchang.text;  
  425.                 ob.离场=addNoteScreen.lichang.text;  
  426.               
  427.                 notes= new ArrayCollection();  
  428.                 notes.addItem(ob);  
  429.                   
  430.                   
  431.                 var temparr:ArrayCollection=new ArrayCollection();  
  432.                 temparr=addNoteScreen.notes;  
  433.                   
  434.                 var xx:XML=TWOarrToXml(notes,temparr);  
  435.                   
  436.                 var ws1:WebService = new WebService();  
  437.                 ws1.loadWSDL(WebServiceUrl);  
  438.                   
  439.                 ws1.insertTable.addEventListener(ResultEvent.RESULT, resultInsert);  
  440.                   
  441.                 //ws1.insertTable.send(xxString);  
  442.                   
  443.                   
  444.                 //xxString="<线路名>640路<路牌名>88<圈>88  <实施时间>2012-06-10<报到>88<工时>88 <出场>88 <离场>88 <首站1>765<末站1>654 <首站2>543<末站2>432<首站3>321<末站3>210";  
  445.                 //ws.GetBusRunTimeList.send();  
  446.                 xxString=xx.toXMLString();  
  447.                 //trace(xxString);  
  448.                 ws1.insertTable.send(xxString);  
  449.             //trace(xxString);  
  450.             //  trace(notes.toString());  
  451.                 //trace(arr1.toString());  
  452.                 //trace(arr2.toString());  
  453.                 PopUpManager.removePopUp(addNoteScreen);   
  454.                   
  455.                 //var upadteString:String=  
  456.             }   
  457.               
  458.           
  459.               
  460.               
  461.             private function resultInsert(e:ResultEvent):void{  
  462.             var sh:String=String(e.result);  
  463.             getdata();  
  464.            if(sh=="success")  
  465.            {  
  466.                  
  467.             Alert.show("插入成功!","成功");  
  468.            }  
  469.            else  
  470.            {  
  471.              Alert.show("插入失败!","失败");  
  472.            }  
  473.               
  474.               
  475.             }  
  476.             private function deletePiece(event:CloseEvent):void{  
  477.               
  478.               
  479.                 if (event.detail==Alert.YES){  
  480.                       
  481.                       
  482.                     if (dataGrid.selectedItems == null)    
  483.                         return;    
  484.                     var index:int=0;    
  485.                     var seledIndexs:int=dataGrid.selectedIndex;    
  486.                     //for (var i:int=0; i < seledIndexs.length; i++)    
  487.                     //{    
  488.                     //index=seledIndexs[i];    
  489.                     //dgDataArr[0]["线路名"]  
  490.                  //var id:Number=xxfc(seledIndexs) as Number;  
  491.           
  492.                     //trace(xxfc(seledIndexs));  
  493.                     var s:String=(dgDataArr[seledIndexs]["OBJECTID"].toString());  
  494.                     //delete(dgDataArr[seledIndexs]);  
  495.                     //notes.removeItemAt(seledIndexs);  
  496.                     var deletewsl:WebService=new WebService();  
  497.                     deletewsl.loadWSDL(WebServiceUrl);  
  498.                       
  499.                     deletewsl.deleteData.addEventListener(ResultEvent.RESULT, resultDelete);  
  500.                     deletewsl.deleteData.send(s);  
  501.                     delete(dgDataArr[seledIndexs]);  
  502.                     //ObObArr.splice(0,ObObArr.length);  
  503.                     //refreshObOb();  
  504.                     //delete(ObObArr[seledIndexs]);  
  505.                 }  
  506.                       
  507.             }  
  508.             private function resultDelete(e:ResultEvent):void  
  509.             {  
  510.                 var sh:String=String(e.result);  
  511.                 getdata();  
  512.                 if(sh=="success")  
  513.                 {  
  514.                     Alert.show("删除成功!","成功");  
  515.                 }  
  516.                 else  
  517.                 {  
  518.                     Alert.show("删除失败!","失败");  
  519.                 }  
  520.             }  
  521.               
  522.             private var updateO:String;  
  523.             private function updatePiece():void{  
  524.               
  525.                 UpdateNoteScreen.ObObArr=ObObArr;  
  526.                   
  527.                 UpdateNoteScreen.oldLupai=dgDataArr[seledIndexs]["路牌名"].toString();  
  528.                 updateO=dgDataArr[seledIndexs]["OBJECTID"].toString();  
  529.                 PopUpManager.addPopUp(UpdateNoteScreen, thistrue);    
  530.                 PopUpManager.centerPopUp(UpdateNoteScreen);   
  531.                   
  532.                   
  533.                 if (dataGrid.selectedItems == null)    
  534.                     return;    
  535.                 var index:int=0;    
  536.                 var seledIndexs:int=dataGrid.selectedIndex;    
  537.       
  538.                 UpdateNoteScreen.lupai.text=dgDataArr[seledIndexs]["路牌名"].toString();  
  539.                 UpdateNoteScreen.baodao.text=dgDataArr[seledIndexs]["报到"].toString();  
  540.                 UpdateNoteScreen.chuchang.text=dgDataArr[seledIndexs]["出场"].toString();  
  541.                 UpdateNoteScreen.lichang.text=dgDataArr[seledIndexs]["离场"].toString();  
  542.                 UpdateNoteScreen.gongshi.text=dgDataArr[seledIndexs]["工时"].toString();  
  543.                 UpdateNoteScreen.quan.text=dgDataArr[seledIndexs]["圈"].toString();  
  544.                 //UpdateNoteScreen.time.text=dgDataArr[seledIndexs]["实施时间"].toString();  
  545.     
  546.                 var notes:ArrayCollection=new ArrayCollection();  
  547.                 //trace(dgDataArr[seledIndexs]["此长"].toString());  
  548.                 var len:int=int(dgDataArr[seledIndexs]["此长"].toString());  
  549.                 //trace(len.toString());  
  550.                 for(var i:int=1;i<=len;i++)  
  551.                 {  
  552.                     var sh:String="首站"+i;  
  553.                     var mo:String="末站"+i;  
  554.                       
  555.                     var ob:Object=new Object();  
  556.                     //trace(sh);  
  557.                     //trace(dgDataArr[seledIndexs][sh].toString());  
  558.                     ob.首站=dgDataArr[seledIndexs][sh].toString();  
  559.                     ob.末站=dgDataArr[seledIndexs][mo].toString();  
  560.                     //note.author = addNoteScreen.author.text;   
  561.                     //note.topic = addNoteScreen.topic.text;   
  562.                     //note.description = addNoteScreen.description.text;   
  563.                       
  564.                     notes.addItem(ob);  
  565.                     //trace(notes.length.toString());  
  566.                     //UpdateNoteScreen.shoumo.dataProvider=notes;  
  567.                     UpdateNoteScreen.notes=notes;  
  568.                     UpdateNoteScreen.shoumo.dataProvider=UpdateNoteScreen.notes;  
  569.                       
  570.                       
  571.                 }  
  572.                   
  573.             }  
  574.               
  575.             private function deleteAsk():void  
  576.             {  
  577.                 Alert.show("确定删除?","系统提示",(1|2),this,deletePiece);  
  578.             }  
  579.         ]]>  
  580.       
  581.       
  582.     "公交时刻行车计划表"    
  583.              width="100%" height="100%">   
  584.         "0" y="0" width="100%" height="100%" gap="0" horizontalAlign="left"  
  585.                   verticalAlign="top">  
  586.             "100%" height="29">  
  587.                 "100%" height="30">  
  588.                     "companyName" x="19" y="10" text="公司名称:杨高公交"/>  
  589.                     "runTimeTable" x="374" y="10" text="行车时刻计划表"/>  
  590.                     "doTime" x="739" y="11" text="实施日期:"/>  
  591.                       
  592.                   
  593.               
  594.             "100%" height="27">  
  595.                 "增加" click="addNote()"/>  
  596.                 "删除" click="deleteAsk()"/>  
  597.                 "修改" click="updatePiece()"/>  
  598.               
  599.             "100%" id="showDT"  height="90%">  
  600.               
  601.                   
  602.               
  603.               
  604.               
  605.           
  606.       
  607.   


点击增加,弹出AddBusLineRunTime.mxml,界面如下: 
flex 多级窗口互调连接oracle动态管理生成动态datagrid_第2张图片  


代码如下: 
Java代码 
  1. "1.0" encoding="utf-8"?>  
  2.   
  3. "library://ns.adobe.com/flex/mx"  
  4.                  xmlns:fx="http://ns.adobe.com/mxml/2009"  
  5.                  layout="absolute" width="498" height="598"    
  6.                  title="增加一条数据" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="init()">    
  7.       
  8.         
  9.             import mx.collections.ArrayCollection;  
  10.             import mx.controls.Alert;  
  11.             import mx.managers.PopUpManager;    
  12.               
  13.               
  14. //          [Bindable]    
  15.             public var notes:ArrayCollection=new ArrayCollection();   
  16.               
  17.             public var ObObArr:Array=new Array();  
  18.               
  19.             private var addNoteScreen:AddShouMo;   
  20.               
  21.             private var WebServiceUrl:String="http://localhost:8081/AnalysisBL.asmx?wsdl";  
  22.               
  23.           
  24.             private function close():void    
  25.             {    
  26.                 PopUpManager.removePopUp(this);    
  27.             }    
  28.             private function save():void{  
  29.                   
  30. //              for(var i:int=0;i  
  31. //              {  
  32. //               // trace(ObObArr[i].toString());  
  33.             //  }  
  34.                 if(ObObArr.indexOf(lupai.text.toString())==-1)  
  35.                 {  
  36.                   
  37.                 this.dispatchEvent(new Event("SaveNote"));   
  38.                 }  
  39.                 else  
  40.                 {  
  41.                   
  42.                 Alert.show("已经存在该路牌名!请重新输入!");  
  43.                 }  
  44.             }  
  45.               
  46.             private function init():void{  
  47.               
  48.                 addNoteScreen = new AddShouMo();    
  49.                 addNoteScreen.addEventListener("SaveShouMo", SaveShouMo);    
  50.             }  
  51.               
  52.             private function add():void{  
  53.               
  54.                 PopUpManager.addPopUp(addNoteScreen, thistrue);    
  55.                 PopUpManager.centerPopUp(addNoteScreen);    
  56.                 //addNoteScreen.author.text = "";    
  57.                 //addNoteScreen.topic.text = "";    
  58.                 //addNoteScreen.description.text = "";    
  59.                   
  60.                   
  61.             }  
  62.               
  63.             private function SaveShouMo(e:Event):void   
  64.             {   
  65.                   
  66. //              notes=   
  67. //              if(notes.length!=0)  
  68. //              {  
  69. //                  notes.removeAll();  
  70. //              }  
  71.                 //var note:Note = new Note();   
  72.                 var ob:Object=new Object();  
  73.                  ob.首站=addNoteScreen.shouzhan.text;  
  74.                 ob.末站=addNoteScreen.mozhan.text;  
  75.                 //note.author = addNoteScreen.author.text;   
  76.                 //note.topic = addNoteScreen.topic.text;   
  77.                 //note.description = addNoteScreen.description.text;   
  78.                 notes.addItem(ob);   
  79.                 PopUpManager.removePopUp(addNoteScreen);   
  80.                 shoumo.dataProvider=notes;  
  81.                   
  82.             }   
  83.               
  84.             private function shanchu():void{  
  85.               
  86.               
  87.                 if (shoumo.selectedItems == null)    
  88.                     return;    
  89.                 var index:int=0;    
  90.                 var seledIndexs:int=shoumo.selectedIndex;    
  91.                 //for (var i:int=0; i < seledIndexs.length; i++)    
  92.                 //{    
  93.                     //index=seledIndexs[i];    
  94.                     notes.removeItemAt(seledIndexs);    
  95.                 //}    
  96.               
  97.             }  
  98.               
  99.         ]]>  
  100.       
  101.       
  102.         [Event(name="SaveNote")]    
  103.       
  104.       
  105.         "35" y="10" text="路牌"/>    
  106.         "lupai" width="150" x="84" y="8"/>    
  107.         "报到"  y="36" x="35"/>    
  108.         "baodao" width="150" x="84" y="34"/>    
  109.         "取消" x="233" y="490" click="close()"/>    
  110.         "保存" x="344" y="490" click="save()"/>    
  111.     "37" y="75" text="出场"/>  
  112.     "chuchang" x="84" y="65" width="150"/>  
  113.     "37" y="110" text="离场"/>  
  114.     "37" y="147" text="工时"/>  
  115.     "43" y="185" text="圈"/>  
  116.     "lichang" x="84" y="100" width="150"/>  
  117.     "gongshi" x="84" y="137" width="150"/>  
  118.     "quan" x="84" y="175" width="150"/>  
  119.     "84" y="234" width="148" height="234" requestedRowCount="4" id="shoumo">  
  120.           
  121.               
  122.                 "首站" headerText="首站">  
  123.                 "末站" headerText="末站">  
  124.                   
  125.               
  126.           
  127.       
  128.       
  129.     "84" y="205" label="增加" click="add()"/>  
  130.     "162" y="205" label="删除" click="shanchu()"/>  
  131.       
  132.       
  133.       
  134.     


此页面又弹出添加AddShouMo.mxml,添加任意组首末站的界面: 
flex 多级窗口互调连接oracle动态管理生成动态datagrid_第3张图片  

代码如下: 
Java代码 
  1. "1.0" encoding="utf-8"?>  
  2.   
  3. "library://ns.adobe.com/flex/mx"  
  4.                  xmlns:fx="http://ns.adobe.com/mxml/2009"  
  5.                  layout="absolute" width="348" height="138"    
  6.                  title="增加首末站">    
  7.       
  8.         
  9.             import mx.managers.PopUpManager;    
  10.               
  11.             private function close():void    
  12.             {    
  13.                 PopUpManager.removePopUp(this);    
  14.             }    
  15.             private function save():void{  
  16.                 this.dispatchEvent(new Event("SaveShouMo"));   
  17.             }  
  18.               
  19.         ]]>  
  20.       
  21.       
  22.         [Event(name="SaveShouMo")]    
  23.       
  24.       
  25.     "首站" x="35" y="10"/>    
  26.     "shouzhan" width="150" x="84" y="8"/>    
  27.     "末站"  y="36" x="35"/>    
  28.     "mozhan" width="150" x="84" y="34"/>    
  29.     "取消" x="154" y="69" click="close()"/>    
  30.     "保存" x="257" y="68" click="save()"/>    
  31.       
  32.     


再然后就是一个修改的页面:UpdateBusLineRunTm.mxml界面如下: 

flex 多级窗口互调连接oracle动态管理生成动态datagrid_第4张图片  
代码如下:
Java代码 
  1. "1.0" encoding="utf-8"?>  
  2.   
  3. "library://ns.adobe.com/flex/mx"  
  4.                  xmlns:fx="http://ns.adobe.com/mxml/2009"  
  5.                  layout="absolute" width="498" height="598"    
  6.                  title="增加一条数据" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="init()">    
  7.       
  8.         
  9.             import mx.collections.ArrayCollection;  
  10.             import mx.controls.Alert;  
  11.             import mx.managers.PopUpManager;    
  12.               
  13.               
  14.             [Bindable]    
  15.             public var notes:ArrayCollection=new ArrayCollection();   
  16.               
  17.             public var ObObArr:Array=new Array();  
  18.               
  19.             private var addNoteScreen:AddShouMo;   
  20.               
  21.               
  22.             public var oldLupai:String;  
  23.               
  24.             private function close():void    
  25.             {    
  26.                 PopUpManager.removePopUp(this);    
  27.             }    
  28.             private function save():void{  
  29.                 if(lupai.text.toString()==oldLupai)  
  30.                 {  
  31.                     this.dispatchEvent(new Event("SaveNote"));   
  32.                 }  
  33.                 if(ObObArr.indexOf(lupai.text.toString())==-1)  
  34.                 {  
  35.                 this.dispatchEvent(new Event("SaveNote"));   
  36.                 }  
  37.                 else  
  38.                 {  
  39.                       
  40.                     Alert.show("已经存在该路牌名!请重新输入!");  
  41.                 }  
  42.             }  
  43.               
  44.             private function init():void{  
  45.                   
  46.                 addNoteScreen = new AddShouMo();    
  47.                 addNoteScreen.addEventListener("SaveShouMo", SaveShouMo);    
  48.                 //shoumo.dataProvider=notes;  
  49.             }  
  50.               
  51.             private function add():void{  
  52.                   
  53.                 PopUpManager.addPopUp(addNoteScreen, thistrue);    
  54.                 PopUpManager.centerPopUp(addNoteScreen);    
  55.                 //addNoteScreen.author.text = "";    
  56.                 //addNoteScreen.topic.text = "";    
  57.                 //addNoteScreen.description.text = "";    
  58.                   
  59.                   
  60.             }  
  61.               
  62.             private function SaveShouMo(e:Event):void   
  63.             {   
  64.                   
  65.                 //              notes=   
  66.                 //              if(notes.length!=0)  
  67.                 //              {  
  68.                 //                  notes.removeAll();  
  69.                 //              }  
  70.                 //var note:Note = new Note();   
  71.                 var ob:Object=new Object();  
  72.                 ob.首站=addNoteScreen.shouzhan.text;  
  73.                 ob.末站=addNoteScreen.mozhan.text;  
  74.                 //note.author = addNoteScreen.author.text;   
  75.                 //note.topic = addNoteScreen.topic.text;   
  76.                 //note.description = addNoteScreen.description.text;   
  77.                 notes.addItem(ob);   
  78.                 PopUpManager.removePopUp(addNoteScreen);   
  79.             //  shoumo.dataProvider=notes;  
  80.                   
  81.             }   
  82.               
  83.             private function shanchu():void{  
  84.                   
  85.                   
  86.                 if (shoumo.selectedItems == null)    
  87.                     return;    
  88.                 var index:int=0;    
  89.                 var seledIndexs:int=shoumo.selectedIndex;    
  90.                 //for (var i:int=0; i < seledIndexs.length; i++)    
  91.                 //{    
  92.                 //index=seledIndexs[i];    
  93.                 notes.removeItemAt(seledIndexs);    
  94.                 //}    
  95.                   
  96.             }  
  97.               
  98.         ]]>  
  99.       
  100.       
  101.         [Event(name="SaveNote")]    
  102.       
  103.       
  104.     "35" y="10" text="路牌"/>    
  105.     "lupai" width="150" x="84" y="8"/>    
  106.     "报到"  y="36" x="35"/>    
  107.     "baodao" width="150" x="84" y="34"/>    
  108.     "取消" x="209" y="539" click="close()"/>    
  109.     "保存" x="291" y="539" click="save()"/>    
  110.     "37" y="75" text="出场"/>  
  111.     "chuchang" x="84" y="65" width="150"/>  
  112.     "37" y="110" text="离场"/>  
  113.     "37" y="147" text="工时"/>  
  114.     "43" y="185" text="圈"/>  
  115.     "lichang" x="84" y="100" width="150"/>  
  116.     "gongshi" x="84" y="137" width="150"/>  
  117.     "quan" x="84" y="175" width="150"/>  
  118.     "81" y="258" width="148" height="234" requestedRowCount="4" id="shoumo" >  
  119.           
  120.               
  121.                 "首站" headerText="首站">  
  122.                 "末站" headerText="末站">  
  123.                   
  124.               
  125.           
  126.           
  127.       
  128.     "81" y="215" label="增加" click="add()"/>  
  129.     "164" y="215" label="删除" click="shanchu()"/>  
  130.       
  131.       
  132.       
  133.     


下面说下这其中的难点:  
源代码,和后台webservice以及数据库文件在附件中,其中涉及到一个数据传输的问题,webservice可以传输可以序列化的数据类型,本demo中,是以xml的方式传输的,webservice,我用c#写的,首先就是连接数据库,这里使用的OLEDB连接的数据库:首先在web.config中加入如下字段: 
Java代码 
  1.   
  2.    "oracleconnection" value="Provider=MSDAORA;Persist Security Info=true;User ID=pdjt;password=pdjt;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxxxxxxxxxxxxxxooooooooooooooooooo)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"/>  
  3.    
  4.    "SDEServer" value="xxxxxxxxxxxxxxxxxxooooooooooooooooooo"/>  
  5.    "SDEInstance" value="5151"/>  
  6.    "SDEUser" value="pdjt"/>  
  7.    "SDEPwd" value="pdjt"/>  
  8.    "SDEDatabase" value="ORCL"/>  
  9.    "SDEVersion" value="SDE.DEFAULT"/>  
  10.    "bufferDistance" value="5"/>  
  11.    "filterDistance" value="10"/>  
  12.    

然后连接数据库 
Java代码 
  1. //连接并打开数据库  
  2.         string connString = System.Configuration.ConfigurationManager.AppSettings["oracleconnection"];  
  3.         OleDbConnection conn = new OleDbConnection(connString);  
  4.         conn.Open();  


由于是同时操作一对多的两张表,增删改,我们如何保证数据的一致性和完整性呢 
先建立一个序列 

Java代码 
  1. CREATE SEQUENCE "PDJT"."NewSequence"  
  2.  INCREMENT BY 1  
  3.  MINVALUE 1  
  4.  MAXVALUE 2147483647  
  5.  START WITH 161  
  6.  CACHE 20;  
  7.   
  8. GRANT SELECT, ALTER ON "PDJT"."NewSequence" TO PUBLIC;  

      每次插入,先从序列拿到值: 
Java代码 
  1. string sql = "Select YZN001.nextval from dual";  
  2.      OleDbCommand commsql = new OleDbCommand(sql, conn);  
  3.      double OBJECTID=Convert.ToDouble(commsql.ExecuteScalar()) ;  

同时插入主表和附表就保证了主键的唯一性以及主表附表的数据的完整性 
取得收据,后要生成xml,传给前台 
Java代码 
  1.  XmlDocument doc = new XmlDocument();  
  2.  doc.AppendChild(doc.CreateElement("result"));  
  3. XmlElement item = doc.CreateElement("item");  
  4.  XmlElement nodeZhanZhang = doc.CreateElement("站长");  
  5.         nodeZhanZhang.InnerText = maxIN.ToString();  
  6.         item.AppendChild(nodeZhanZhang);  
  7.   
  8.         XmlElement nodeCiChang = doc.CreateElement("此长");  
  9.         nodeCiChang.InnerText = tbl.Rows.Count.ToString();  
  10.         item.AppendChild(nodeCiChang);  
  11. .........doc.LastChild.AppendChild(item);  
  12.         return doc.InnerXml;  




前台到后台的xml的遍历: 
Java代码 
  1. XmlDocument doc = new XmlDocument();  
  2.       doc.LoadXml(xmlString);  
  3.       
  4.        
  5.         
  6.             ArrayList headersubList = new ArrayList();  
  7.                 //获取当前XML文档的根 一级  
  8.             XmlNode oNode = doc.DocumentElement;  
  9.          
  10.                 //获取根节点的所有子节点列表   
  11.                 XmlNodeList oList = oNode.ChildNodes;  
  12.   
  13.                 //标记当前节点  
  14.                 XmlNode oCurrentNode;  
  15.                 //遍历所有二级节点  
  16.                 for (int i = 0; i < oList.Count; i++)  
  17.                 {  
  18.                     //二级  
  19.                     oCurrentNode = oList[i];  
  20.                    // 线路名 = oList[i].Value;  
  21.                     //检测当前节点的名称,节点的值是否与已知匹配  
  22.                     if (oCurrentNode.Name.ToLower().Equals("item"))  
  23.                     {  
  24.                         //检测是否有子节点 三级  
  25.                         if (oCurrentNode.HasChildNodes)  
  26.                         {  
  27.                             //Console.WriteLine(oCurrentNode.ChildNodes.Count);  
  28.   
  29.   
  30.                               
  31.                             //遍历当前节点的所有子节点  
  32.                             for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++)  
  33.                             {  


oracle时间类型的处理: 
Java代码 
  1.    
  2. public string 实施时间 = "2012-06-05";  
  3.   
  4. to_date('" + 实施时间 + "','yyyy-mm-dd'));  

关于oracle时间处理的详解: 
ORACLE/JSP技术涉及日期、时间问题的处理 
(1)在英文版本的ORACLE中默认日期格式为'DD-MON-YY',例如'01-JAN-98' 
  在汉化的中文版本中ORACLE默认日期格式为'日-月-年',例如'21-8月-2003'或'21-8月-03' 
(2)转换字符串为日期 
使用ORACLE内部函数to_date() 
to_date()函数的参数是to_char()函数参数的反转。 
to_date(string_value , date_format) 
变量定义如下: 
string_value :为字符串直接值(字符串本身)、字符串列(数据库中定义的某个表的某列)或某字符串内部函数的返回值。 
date_format为合法的Oracle日期格式。 
下列更新语句均符合ORACLE的日期格式,更新成功: 
create table student (name varchar2(10) not null primary key , enrolldate date not null);//创建student表 
insert into student values('mark',to_date('08-21-2003','MM-DD-YYYY')); 

insert into student values('mark1',to_date('21-08-2003','DD-MM-YYYY')); 

insert into student values('mark2','21-8月-2003'); 

insert into xiongxiaomin.student values('mark3','21-8月-03'); 
(3)转换日期为字符串 
使用ORACLE内部函数to_char() 
to_char(date_value,date_format) 
变量定义如下: 
date_value :为日期型直接值(日期本身)、日期型列值(数据库中定义的某个表的某列)或某内部函数的返回的日期型值。 
date_format为合法的Oracle日期格式。 

选择enrolldate字段的时间部分: 
select (to_char(enrolldate,'HH24:MI:SS'))enrolldate from  student; 

(4)注意:ORACLE中的date数据类型定义的列包含日期和时间。 
1、系统当前日期为2003年8月21日,之后执行下列语句 
insert into student values('mark5',to_date('09:28:03','HH:MI:SS'));//注意此种在一条记录的date类型字段中插入时间的方法,系统默认的日期为系统当前日期所在月份的第一天,因此得到的记录为 

Name            enrolldate 

mark5    01-八月 -2003 09:28:03 AM 

2、修改系统当前日期为2003年7月21日,之后执行下列语句 
insert into student values('mark6',to_date('09:28:03','HH:MI:SS')); 
得到的记录为 
Name            enrolldate 

mark6     01-七月 -2003 09:28:03 AM 

insert into student values('mark8',to_date('20:28:03','HH24:MI:SS')); 

3、同时在一条记录中插入日期和时间的方法 
insert into student values('mark9',to_date('21-08-2003 
20:28:03','DD-MM-YYYY HH24:MI:SS'));//同时在一条记录中插入日期和时间的方法 

insert into student values('mark',to_date('21-08-2003 
09:52:03','DD-MM-YYYY HH:MI:SS'));//同时在一条记录中插入日期和时间的方法 

注意不能使用下列方法同时插入日期和时间 
insert into student values('mark2','21-8月-2003'+to_date(' 
09:52:03','HH:MI:SS'));//无效插入记录方法 

4、在SQL*Plus Worksheet中执行下列SQL语句 
select * from student; 
得到的记录结果如下:注意date类型字段中只显示了日期,时间并未显示 
NAME                 ENROLLDATE 

mark               18-8月 -03 
mark1              21-8月 -03 
mark2              21-8月 -03 



已选择3行。 




5、但在JSP程序中同样执行select * from student order by enrolldate 
显示结果见下图(既显示了日期,又显示了时间) 

                         JSP页面中的显示结果 
6、在SQL*Plus Worksheet中执行下列SQL语句 
select name,to_char(enrolldate,'DD-MM-YYYY HH:MI:SS') from student; 
得到的记录结果如下:注意date类型字段中显示了日期和时间 
NAME                 TO_CHAR(ENROLLDATE,'DD-MM-YYYYHH:MI:SS 
mark               21-08-2003 12:00:00 
mark1              21-08-2003 12:00:00 

已选择2行 
注意:5和6中的不同,时间到秒时,JSP页面中显示时多出了". 0" 
7、在SQL*Plus Worksheet中执行下列SQL语句 
select name,to_char(enrolldate,'DD-MM-YYYY HH24:MI:SS') from student; 
得到的记录结果如下:注意date类型字段中显示了日期,时间 
NAME                 TO_CHAR(ENROLLDATE,'DD-MM-YYYYHH24:MI: 

mark               18-08-2003 17:40:20 
mark1              21-08-2003 00:00:00 
mark2              21-08-2003 00:00:00 

已选择3行。 
注意:6和7中的SELECT中的"HH:MI:SS"和"HH24:MI:SS"两者的不同是"HH"为小时制,值的范围为0-12;"HH24"为24小时制,值的范围为0-23。 
   看下列例子: 
①insert into student values('南太里',to_date('08-19-2003 
13:54:05','MM-DD-YYYY HH24:MI:SS')); 
ORACLE中的记录结果为: 
NAME                   enrolldate 
南太里                19-八月 -2003 01:54:05 PM 
②insert into student values('南太里2',to_date('08-19-2003 
13:54:05','MM-DD-YYYY HH:MI:SS'));//插入错误 
错误提示为: 
insert into student values('南太里2',to_date('08-19-2003 13:54:05','MM-DD 
                                                          * 
ERROR 位于第 1 行: 
ORA-01849: 小时值必须介于 1 和 12 之间 
即应用"HH"时,不能应用"13:54:05",而应改为"01:54:05" 
正确语句如下: 
insert into student values('南太里2',to_date('08-19-2003 
01:54:05','MM-DD-YYYY HH:MI:SS')); 
ORACLE中的记录结果为: 
NAME                   enrolldate 

南太里2              19-八月 -2003 01:54:05 AM 
注意上述两种方式得出的结果一种为PM,另一种为AM。 
为了提高正确性,建议都是用地一种方式"HH24" 
8、但在JSP程序中同样执行select name,to_char(enrolldate,'DD-MM-YYYY HH:MI:SS') from student 
显示结果见下图。(其结果与在SQL*Plus Worksheet中执行下列SQL语句 
select name,to_char(enrolldate,'DD-MM-YYYY HH:MI:SS') from student;相同) 
9、在SQL*Plus Worksheet中执行下列SQL语句 
select name,to_char(enrolldate,'month dd,yyyy HH24:MI:SS') from student; 
得到的记录结果如下:注意date类型字段中显示了日期,时间 
NAME                 TO_CHAR(ENROLLDATE,'MONTHDD,YYYYHH24:MI:SS') 

mark               8月  18,2003 17:40:20 
mark1              8月  21,2003 00:00:00 
mark2              8月  21,2003 00:00:00 

已选择3行。 
10、to_char()函数,'DD-MM-YYYY'格式及'MM-DD-YYYY'格式和'month dd,yyyy'格式的不同 
'DD-MM-YYYY'格式:21-08-2003 
'month dd,yyyy'格式:8月  21,2003 

11、注意:在日期和时间格式中非常容易混淆的是月份和秒的格式(即MM和MI) 
在SQLPlus*Worksheet中执行下列语句,不报错。 
insert into student values('王嘉',to_date('08:05','HH24:MM'));//08被认为是小时,05被认为是月份。 
commit; 
在表编辑器中查看:实际插入值为 
NAME                 ENROLLDATE 
王嘉    01-五月 -2003 08:00:00 AM 

select name,to_char(enrolldate,'DD-MM-YYYY HH24:MI:SS')enrolldate from 
student where name='王嘉'; 

NAME                 ENROLLDATE 
王嘉                 01-05-2003 08:00:00 

已选择 1 行。 

insert into student values('汪嘉2',to_date('08-19-2003 
13:54:05','MM-DD-YYYY HH24:MI:SS')); 


12、使用Oracle的date数据类型的另一个优点是:它支持日期的运算。可以对已经存在的 

日期加上或减去若干天,例如: 
insert into student values('熊',sysdate+7); 


还有一个问题就是附表主键自增长问题,写一个序列和触发器: 
序列: 
Java代码 
  1. CREATE SEQUENCE "PDJT"."NewSequence"  
  2.  INCREMENT BY 1  
  3.  MINVALUE 1  
  4.  MAXVALUE 2147483647  
  5.  START WITH 281  
  6.  CACHE 20;  
  7.   
  8. GRANT SELECT, ALTER ON "PDJT"."NewSequence" TO PUBLIC;  

触发器: 
Java代码 
  1. CREATE OR REPLACE TRIGGER "PDJT"."NewTrigger" BEFORE INSERT ON "PDJT"."公交线路行车时刻计划表附表" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW  
  2. BEGIN  
  3. SELECT YZN002.NEXTVAL INTO :NEW.OBJECTID FROM DUAL;  
  4. END;  
  5.   
  6.   
  7.   
  8. ;  
  9.   
  10. ALTER TRIGGER "PDJT"."NewTrigger" ENABLE;  

flex前端,xml转array: 
Java代码 
  1. private function xmlListToArray(results:XMLList):Array     
  2.             {     
  3.                 var array:Array=new Array();     
  4.                 for each(var child:XML in results)     
  5.                 {     
  6.                     var obj:Object=new Object();     
  7.                     //obj[child.nodeKind()]=child[child.nodeKind()];     
  8.                     for each(var ite:XML in child.children())     
  9.                     {     
  10.                         obj[ite.name().toString()]=child[ite.name().toString()];     
  11.                     }     
  12.                       
  13.                     //array.addItem(obj);  
  14.                     array.push(obj);  
  15.                 }     
  16.                 return array;     
  17.             }    

array转xml 
Java代码 
  1. private function arrToXml(arr:ArrayCollection):XML{      
  2.                 var root:XML = new XML("");      
  3.                 for(var i:int = 0;i
  4.                     var node:XML = new XML("");      
  5.                      
  6.                       
  7.                     node.线路名=arr[i].线路名;  
  8.                     node.路牌名=arr[i].路牌名;  
  9.                     node.圈=arr[i].圈;  
  10.                     node.实施时间=arr[i].实施时间;  
  11.                     node.报到=arr[i].报到;  
  12.                     node.工时=arr[i].工时;  
  13.                     node.出场=arr[i].出场;  
  14.                     node.离场=arr[i].离场;  
  15.                           
  16.                           
  17.                     root.appendChild(node);      
  18.                 }      
  19.                 return root;      
  20.             }      

其他见附件:地址:http://yangactive.iteye.com/blog/1561610

你可能感兴趣的:(flex,oracle,datagrid,flex,string,webservice,date)