关闭

Flex 实现简单的增删改,运用到监听器

671人阅读 评论(0) 收藏 举报
import mx.skins.halo.TitleBackground;
   import mx.containers.Tile;
   import mx.collections.ArrayCollection;
   import mx.managers.PopUpManager;
   import mx.rpc.events.ResultEvent;
   import mx.controls.Alert;
   import BusyCode.Web.Shared.*;
   private var ac:ArrayCollection;
   private var obj:Object;
   
    private function init():void
   {
      Data.WebServiceInit(Local_Config.sWEB_SERVICE);
      this.show_data();
   }
   
   private function show_data():void
   {
    
     var Sql:String="select * from test_Time order by ID  desc";
      Data.database_query(Sql,result_show_data,"result_show_data");
    
     }
   private function result_show_data(event:ResultEvent):void
   {
      if(Data.database_query_removeListener(event,result_show_data,"result_show_data"))
       return;
       var dataset:XML=new XML(event.result.toString());
       this.dg_id.dataProvider=dataset.Table;
    }
   private var bw:Bt=new Bt();
   private function bnt_clickinsadd():void{
    this.addTitlewindow("添加");
    bw.addEventListener("remove",addDate);
   }
   private function addDate(event:Event):void{
    var sql:String="insert into test_Time values('"+bw.tin_times.text
    +"','"+bw.tin_timee.text+"','"+bw.tin_tatter.text+"')";
    Data.database_query(sql,result_add,"result_add");
   }
   private function result_add(event:ResultEvent):void{
    if(Data.database_query_removeListener(event,result_add,"result_add"))
    return;
    var dataset:XML=new XML(event.result.toString());
    this.init();
    
   }
   private function bnt_clickinsup():void{
    if(this.dg_id.selectedIndex<0){
     Alert.show("请选择一个数据行","没有选择行");
    }else{
    this.addTitlewindow("修改");
    bw.tin_id.text=this.dg_id.selectedItem.ID;
    bw.tin_times.text=this.dg_id.selectedItem.TimeS;
    bw.tin_timee.text=this.dg_id.selectedItem.TimeE;
    bw.tin_tatter.text=this.dg_id.selectedItem.Matter;
    bw.addEventListener("remove",updates);
    }
   }
   private function updates(event:Event):void{
    var sql:String="update test_Time set TimeS='"+bw.tin_times.text+"',TimeE='"+bw.tin_timee.text+"'," +
      "Matter='"+bw.tin_tatter.text+"' where ID="+bw.tin_id.text;
      Data.database_query(sql,result_updat,"result_updat");
   }
   private function result_updat(event:ResultEvent):void{
    if(Data.database_query_removeListener(event,result_updat,"result_updat"))
    return;
    var dataset:XML=new XML(event.result.toString());
    this.init();
   }
   private function bnt_clickinsdel():void{
    if(this.dg_id.selectedIndex<=0){
     Alert.show("请选择一个数据行","没有选择行");
    }else{
    this.addTitlewindow("删除");
    bw.tin_id.text=this.dg_id.selectedItem.ID;
    bw.addEventListener("remove",deletes);
    }
   }
   private function deletes(event:Event):void{
    var sql:String="delete from test_Time where ID="+bw.tin_id.text;
    Data.database_query(sql,result_deletes,"result_deletes");
   }
   private function result_deletes(event:ResultEvent):void{
    if(Data.database_query_removeListener(event,result_deletes,"result_deletes"))
    return;
    var dataset:XML=new XML(event.result.toString());
    this.init();
    }
   private function addTitlewindow(str:String):void{
    if(bw.visible==true)
     PopUpManager.removePopUp(bw);
    PopUpManager.addPopUp(bw,this);
    PopUpManager.centerPopUp(bw);
    bw.title=str;
    bw.bnt_lab.label=str;
    
   } 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:288187次
    • 积分:4385
    • 等级:
    • 排名:第6793名
    • 原创:125篇
    • 转载:77篇
    • 译文:0篇
    • 评论:53条
    最新评论