-----宝宝生日快乐~~!
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;