protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //Dictionary<string, Lib.Unit> units = new Dictionary<string, Lib.Unit>(); Lib.UnitTree tree = new Lib.UnitTree(); Lib.Unit army = tree.GetUnitWithChild("10001"); if (army != null) { if (army.ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child in army.ChildUnit) { MenuItem item = new MenuItem(); item.Text = ((Lib.Unit)child.Value).Unit_Title; item.Value = ((Lib.Unit)child.Value).Unit_Code; Menu1.Items.Add(item); if (((Lib.Unit)child.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d in ((Lib.Unit)child.Value).ChildUnit) { MenuItem item2 = new MenuItem(); item2.Text = ((Lib.Unit)child_d.Value).Unit_Title; item2.Value = ((Lib.Unit)child_d.Value).Unit_Code; item.ChildItems.Add(item2); if (((Lib.Unit)child_d.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d_d in ((Lib.Unit)child_d.Value).ChildUnit) { MenuItem item3 = new MenuItem(); item3.Text = ((Lib.Unit)child_d_d.Value).Unit_Title; item3.Value = ((Lib.Unit)child_d_d.Value).Unit_Code; item2.ChildItems.Add(item3); if (((Lib.Unit)child_d_d.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d_d_d in ((Lib.Unit)child_d_d.Value).ChildUnit) { MenuItem item4 = new MenuItem(); item4.Text = ((Lib.Unit)child_d_d_d.Value).Unit_Title; item4.Value = ((Lib.Unit)child_d_d_d.Value).Unit_Code; item3.ChildItems.Add(item4); } } } } } } } } } } }
protected void Button1_Click(object sender, EventArgs e) { Menu1.Items.Clear(); Dictionary <string, Lib.Unit> units = new Dictionary <string, Lib.Unit>(); Lib.UnitTree tree = new Lib.UnitTree(); Lib.Unit army = tree.GetUnitWithChild(unit_code.Text.Trim()); if (army != null) { if (army.ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child in army.ChildUnit) { MenuItem item = new MenuItem(); item.Text = ((Lib.Unit)child.Value).Unit_Title; item.Value = ((Lib.Unit)child.Value).Unit_Code; Menu1.Items.Add(item); if (((Lib.Unit)child.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d in ((Lib.Unit)child.Value).ChildUnit) { MenuItem item2 = new MenuItem(); item2.Text = ((Lib.Unit)child_d.Value).Unit_Title; item2.Value = ((Lib.Unit)child_d.Value).Unit_Code; item.ChildItems.Add(item2); if (((Lib.Unit)child_d.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d_d in ((Lib.Unit)child_d.Value).ChildUnit) { MenuItem item3 = new MenuItem(); item3.Text = ((Lib.Unit)child_d_d.Value).Unit_Title; item3.Value = ((Lib.Unit)child_d_d.Value).Unit_Code; item2.ChildItems.Add(item3); if (((Lib.Unit)child_d_d.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d_d_d in ((Lib.Unit)child_d_d.Value).ChildUnit) { MenuItem item4 = new MenuItem(); item4.Text = ((Lib.Unit)child_d_d_d.Value).Unit_Title; item4.Value = ((Lib.Unit)child_d_d_d.Value).Unit_Code; item3.ChildItems.Add(item4); } } } } } } } } } }
protected void Button2_Click(object sender, EventArgs e) { Lib.UnitTree Tree = new Lib.UnitTree(); Lib.Unit unit = Tree.GetUnitWithChild("00001"); Lib.DataUtility du = new Lib.DataUtility(); DataTable dt = du.getDataTableByText("select * from unit"); foreach (DataRow row in dt.Rows) { int count = 0; foreach (KeyValuePair <string, string> pair in unit.ChildUnitList) { if (row["unit_code"].ToString() == pair.Key) { count++; } } if (count != 1) { Response.Write(row["unit_code"].ToString() + " , " + row["unit_title"].ToString() + " , " + row["parent_unit_code"].ToString() + "<br />"); } } //foreach (KeyValuePair<string, string> d in unit.ChildUnitList) //{ // int count = 0; // foreach (DataRow row in dt.Rows) // { // if (row["unit_code"].ToString() == d.Key) // { // count++; // } // } // if (count != 1) // { // Response.Write(d.Key + " , " + d.Value + " , " + count.ToString() + "<br />"); // } //} }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["account"] != null) { Lib.Account acc = (Lib.Account)Session["account"]; account.Value = acc.AccountName; #region 選單製作 Lib.UnitTree tree = new Lib.UnitTree(); Lib.Unit army = tree.GetUnitWithChild(acc.Unit_Code); MenuItem selfItem = new MenuItem(); selfItem.Text = acc.Unit; selfItem.Value = acc.Unit_Code; Menu1.Items.Add(selfItem); if (army != null) { if (army.ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child in army.ChildUnit) { MenuItem item = new MenuItem(); item.Text = ((Lib.Unit)child.Value).Unit_Title; item.Value = ((Lib.Unit)child.Value).Unit_Code; Menu1.Items.Add(item); if (((Lib.Unit)child.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d in ((Lib.Unit)child.Value).ChildUnit) { MenuItem item2 = new MenuItem(); item2.Text = ((Lib.Unit)child_d.Value).Unit_Title; item2.Value = ((Lib.Unit)child_d.Value).Unit_Code; item.ChildItems.Add(item2); if (((Lib.Unit)child_d.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d_d in ((Lib.Unit)child_d.Value).ChildUnit) { MenuItem item3 = new MenuItem(); item3.Text = ((Lib.Unit)child_d_d.Value).Unit_Title; item3.Value = ((Lib.Unit)child_d_d.Value).Unit_Code; item2.ChildItems.Add(item3); if (((Lib.Unit)child_d_d.Value).ChildUnit != null) { foreach (KeyValuePair <string, Lib.Unit> child_d_d_d in ((Lib.Unit)child_d_d.Value).ChildUnit) { MenuItem item4 = new MenuItem(); item4.Text = ((Lib.Unit)child_d_d_d.Value).Unit_Title; item4.Value = ((Lib.Unit)child_d_d_d.Value).Unit_Code; item3.ChildItems.Add(item4); } } } } } } } } } #endregion // 設定預設日期 date_start.Value = (DateTime.Now.Year - 1911).ToString() + "/1/1"; date_stop.Value = (DateTime.Now.Year - 1911).ToString() + "/12/31"; } } }