protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ////2016-11-14先判斷是不是有選取單位(先不改)
        //if (DropDownList1.SelectedValue!="00000")
        //{

        //}
        ListItem item = null;

        Lib.Unit unit = new Lib.UnitTree().GetUnitWithChild(DropDownList1.SelectedValue);
        DropDownList2.Items.Clear();
        DropDownList3.Items.Clear();
        DropDownList4.Items.Clear();
        DropDownList5.Items.Clear();
        if (unit.ChildUnit != null && unit.ChildUnit.Count != 0)
        {
            foreach (KeyValuePair <string, Lib.Unit> pair in unit.ChildUnit)
            {
                Lib.Unit child = pair.Value as Lib.Unit;
                item       = new ListItem();
                item.Text  = child.Unit_Title;
                item.Value = child.Unit_Code;
                DropDownList2.Items.Add(item);
            }
        }
    }
    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
    {
        ListItem item = null;

        Lib.Unit unit = new Lib.UnitTree().GetUnitWithChild(DropDownList3.SelectedValue);
        DropDownList4.Items.Clear();
        DropDownList5.Items.Clear();
        if (unit.ChildUnit != null && unit.ChildUnit.Count != 0)
        {
            foreach (KeyValuePair <string, Lib.Unit> pair in unit.ChildUnit)
            {
                Lib.Unit child = pair.Value as Lib.Unit;
                item       = new ListItem();
                item.Text  = child.Unit_Title;
                item.Value = child.Unit_Code;
                DropDownList4.Items.Add(item);
            }
            if (unit.ChildUnit.Count == 1)
            {
                Lib.Unit onlyChild = new Lib.UnitTree().GetUnitWithChild(DropDownList4.Items[0].Value);
                if (onlyChild.ChildUnit != null && onlyChild.ChildUnit.Count != 0)
                {
                    foreach (KeyValuePair <string, Lib.Unit> pair in onlyChild.ChildUnit)
                    {
                        Lib.Unit child = pair.Value as Lib.Unit;
                        item       = new ListItem();
                        item.Text  = child.Unit_Title;
                        item.Value = child.Unit_Code;
                        DropDownList5.Items.Add(item);
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["account"] != null)
            {
                // 設定預設日期
                date_start.Value = (DateTime.Now.Year - 1911).ToString() + "/1/1";
                date_stop.Value  = (DateTime.Now.Year - 1911).ToString() + "/12/31";

                #region 鑑測站程式碼
                DataTable dt = new DataTable();
                dt.Columns.Add("單位名稱");
                dt.Columns.Add("單位代碼");
                DataRow  row  = null;
                Lib.Unit unit = new Lib.UnitTree().GetUnitWithChild("00001");
                if (unit.ChildUnit != null && unit.ChildUnit.Count != 0)
                {
                    foreach (KeyValuePair <string, Lib.Unit> pair in unit.ChildUnit)
                    {
                        Lib.Unit child = pair.Value as Lib.Unit;
                        row    = dt.NewRow();
                        row[0] = child.Unit_Title;
                        row[1] = child.Unit_Code;
                        dt.Rows.Add(row);
                    }
                }
                GridView1.DataSource = dt;
                GridView1.DataBind();
                #endregion

                #region 入口網站的程式碼
                //DropDownList2.Visible = false;
                //Lib.Center.Account_c acc = Session["account"] as Lib.Center.Account_c;
                //ListItem item = null;
                //Lib.Unit unit = new Lib.UnitTree().GetUnitWithChild(acc.Unit_Code);
                //item = new ListItem();
                //item.Text = unit.Unit_Title;
                //item.Value = unit.Unit_Code;
                //DropDownList1.Items.Add(item);
                //if (unit.ChildUnit != null && unit.ChildUnit.Count != 0)
                //{
                //    foreach (KeyValuePair<string, Lib.Unit> pair in unit.ChildUnit)
                //    {
                //        Lib.Unit child = pair.Value as Lib.Unit;
                //        item = new ListItem();
                //        item.Text = child.Unit_Title;
                //        item.Value = child.Unit_Code;
                //        DropDownList1.Items.Add(item);
                //    }
                //}
                #endregion
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }
        }
    }
Beispiel #4
0
 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);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #5
0
    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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #6
0
    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 (Request.QueryString["type"] != null)
        {
            type.Value = Request.QueryString["type"];
            if (type.Value == "rank")
            {
                Label1.Text     = "級職";
                txtAge.Visible  = false;
                ddlRank.Visible = true;
            }
            if (type.Value == "age")
            {
                Label1.Text     = "年齡";
                txtAge.Visible  = true;
                txtAge.Text     = "25-35";
                ddlRank.Visible = false;
            }
            if (type.Value == "item")
            {
                Label1.Visible  = false;
                txtAge.Visible  = false;
                ddlRank.Visible = false;
            }
        }


        if (!Page.IsPostBack)
        {
            if (Session["account"] != null)
            {
                // 設定預設日期
                date_start.Value = (DateTime.Now.Year - 1911).ToString() + "/1/1";
                date_stop.Value  = (DateTime.Now.Year - 1911).ToString() + "/12/31";



                //DropDownList2.Visible = false;
                Lib.Account acc  = Session["account"] as Lib.Account;
                ListItem    item = null;
                Lib.Unit    unit = new Lib.UnitTree().GetUnitWithChild(acc.Unit_Code);

                ////2016-11-14選項先空白(先不改)
                //item = new ListItem();
                //item.Text = string.Empty;
                //item.Value = "00000";
                //DropDownList1.Items.Add(item);

                item       = new ListItem();
                item.Text  = unit.Unit_Title;
                item.Value = unit.Unit_Code;
                DropDownList1.Items.Add(item);

                if (unit.ChildUnit != null && unit.ChildUnit.Count != 0)
                {
                    foreach (KeyValuePair <string, Lib.Unit> pair in unit.ChildUnit)
                    {
                        Lib.Unit child = pair.Value as Lib.Unit;
                        item       = new ListItem();
                        item.Text  = child.Unit_Title;
                        item.Value = child.Unit_Code;
                        DropDownList1.Items.Add(item);
                    }
                }
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }
        }
    }
Beispiel #8
0
    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";
            }
        }
    }