.NET 程序花园

光说不练那是花把式,照不住。光练不说那是在自我陶醉,心要有数。 ~^_^~

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

-----宝宝生日快乐~~!

 DataTable allds = new DataTable();
   allds = rdpo.GetAllDepartment().Tables[0];
   int i= 0;
   i = allds.Rows.Count;
   string[] alldep = new string[i];
   for (int k=0;k<i;k++)
   {
    alldep[k] = allds.Rows[k][1].ToString();
   }
          this.lbxDept.DataSource = alldep ;
    this.lbxDept.DisplayMember = "Department_name";
          this.lbxDept.SelectedIndex=1;

  }
  public void productsDisplay()
  { 
   
   DataTable dt = new  DataTable();
   dt.Columns.Add("Product_id");
   dt.Columns.Add("Product_name");
   try
     {  
       int i= this.lbxDept.SelectedItems.Count;
    string depName="";
    for (int n=0;n<i;n++)                                 //部门-产品集
    {   
     depName = this.lbxDept.SelectedItems[n].ToString();
     for(int k=0;k<rdpo.GetParentProductByDepName(Convert.ToString(depName)).Tables[0].Rows.Count;k++)
     {
      dt.Rows.Add(rdpo.GetParentProductByDepName(Convert.ToString(depName)).Tables[0].Rows[k].ItemArray);
     }   
    }

                Hashtable hash = new Hashtable();
    for(int f=0;f<dt.Rows.Count;f++)
    {
     if(!hash.ContainsValue(dt.Rows[f][1].ToString()))
      { 
       hash.Add(f,dt.Rows[f][1].ToString());
      }
       }
             
    string[]  vv= new string[hash.Count];
            
          int d=0;
    foreach ( DictionaryEntry de in hash )
    {
     vv[d++]=de.Value.ToString();
    }
    
       this.lbxProduct.DataSource  =  vv; 

posted on 2006-07-03 18:21  北回归线  阅读(712)  评论(1编辑  收藏  举报