/// <summary> /// Loads the location tree /// </summary> private void PopulateLocationTree() { BLL.Region reg = new BLL.Region(); Zone zon = new Zone(); Woreda wrd = new Woreda(); reg.LoadAll(); locationTree.Nodes.Clear(); foreach (DataRowView dv in reg.DefaultView) { TreeNode nodes = new TreeNode { Name = "Reg" + dv["ID"].ToString(), Text = dv["RegionName"].ToString(), ToolTipText = "Double Click to Edit." }; zon.GetZoneByRegion(Convert.ToInt32(dv["ID"])); foreach (DataRowView subDv in zon.DefaultView) { TreeNode zonNodes = new TreeNode { Name = "Zon" + subDv["ID"].ToString(), Text = subDv["ZoneName"].ToString(), ToolTipText = "Double Click to Edit." }; wrd.GetWoredaByZone(Convert.ToInt32(subDv["ID"])); foreach (DataRowView worDv in wrd.DefaultView) { TreeNode wrdNodes = new TreeNode { Name = "Wrd" + worDv["ID"].ToString(), Text = worDv["WoredaName"].ToString(), ToolTipText = "Double Click to Edit." }; zonNodes.Nodes.Add(wrdNodes); } nodes.Nodes.Add(zonNodes); } locationTree.Nodes.Add(nodes); } cboRegion.DataSource = reg.DefaultView; }
/// <summary> /// Populates the zones /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cboRegion_SelectedIndexChanged(object sender, EventArgs e) { Zone zn = new Zone(); zn.GetZoneByRegion(Convert.ToInt32(cboRegion.SelectedValue)); cboZone.DataSource = zn.DefaultView; }