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 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 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");
            }
        }
    }
    protected void search3_Click(object sender, EventArgs e)
    {   //單位代碼查詢
        bool isRight = false;

        try
        {
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            Lib.Account acc  = Session["account"] as Lib.Account;
            Lib.Unit    unit = new Lib.UnitTree().GetUnitWithChild(acc.Unit_Code);
            DataTable   _dt  = unit.ChildUnitCodeTable;
            DataSet     ds   = new DataSet();
            foreach (string t in unit.ChildUnitCodeArray)
            {
                if (unit_code.Text.Trim().ToUpper() == t)
                {
                    isRight = true;
                }
            }
            if (isRight)
            {
                d.Clear();
                d.Add("type", "unit_code");
                d.Add("value", unit_code.Text.Trim());
                ds = du.getDataSet("QueryResult", d, "tempTable", _dt);
                GridView3.DataSource = ds.Tables[0];
                GridView3.DataBind();
            }
            else
            {
                this.unitnone.Style.Value = "display:none";
            }
            //if(ds.Tables.Count == 0)
            //if (ds.Tables[0].Rows.Count == 0)
            if (ds.Tables.Count == 0)
            {
                this.unitnone.Style.Value = "";
            }
            else
            {
                this.unitnone.Style.Value = "display:none";
            }
        }
        catch (Exception ex)
        {
            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
            this.unitnone.Style.Value = "";
            GridView3.DataBind();
        }
        finally
        {
            TabContainer1.ActiveTabIndex = 2;
        }
    }
Beispiel #5
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 #6
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 #7
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 search5_Click(object sender, EventArgs e)
 {   //鑑測站與時間查詢 , 另外使用Stroe Precedure
     try
     {
         Lib.DataUtility             du = new Lib.DataUtility();
         Dictionary <string, object> d  = new Dictionary <string, object>();
         Lib.Account acc  = Session["account"] as Lib.Account;
         Lib.Unit    unit = new Lib.UnitTree().GetUnitWithChild(acc.Unit_Code);
         DataTable   _dt  = unit.ChildUnitCodeTable;
         d.Clear();
         d.Add("type", "center");
         d.Add("value", cneterSel.SelectedValue);
         d.Add("date", Lib.SysSetting.ToWorldDate(TextBox1.Text.Trim()).ToShortDateString());
         DataSet ds = du.getDataSet("QueryResultByCenter", d, "tempTable", _dt);
         if (ds.Tables[0].Rows.Count == 0)
         {
             this.centernone.Style.Value = "";
             GridView5.DataBind();
         }
         else
         {
             this.centernone.Style.Value = "display:none";
             GridView5.DataSource        = ds.Tables[0];
             GridView5.DataBind();
         }
     }
     catch (Exception ex)
     {
         Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
         this.centernone.Style.Value = "";
         GridView5.DataBind();
     }
     finally
     {
         TabContainer1.ActiveTabIndex = 4;
     }
 }
    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 #10
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";
            }
        }
    }
    protected void search1_Click(object sender, EventArgs e)
    {   //身份證查詢
        bool isRight = false;

        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Add("id", id.Text.Trim());
        DataTable dt    = du.getDataTableByText("select distinct unit_code from result where id = @id", d);
        DataSet   ds    = new DataSet();
        DataTable dt_id = new DataTable();

        dt_id.Columns.Add("unit_code");
        if (dt.Rows.Count > 0)
        {
            Lib.Account acc  = Session["account"] as Lib.Account;
            Lib.Unit    unit = new Lib.UnitTree().GetUnitWithChild(acc.Unit_Code);
            DataTable   _dt  = unit.ChildUnitCodeTable;

            //綁定三組帳號
            if (acc.AccountName == "admin" | acc.AccountName == "cola" | acc.AccountName == "asz1330")
            {
                isRight = true;
            }
            else
            {
                //只要曾經有一個單位代碼在這底下的就能查他成績
                foreach (string t in unit.ChildUnitCodeArray)
                {
                    if (isRight == true)
                    {
                        break;
                    }
                    foreach (DataRow tt in dt.Rows)
                    {
                        if (isRight == true)
                        {
                            break;
                        }
                        //var check = dt.Rows[0]["unit_code"].ToString().Trim().ToUpper();
                        var check = tt["unit_code"].ToString().Trim().ToUpper();
                        if (check == t)
                        {
                            //dt_id.Rows.Add(check.ToString().Trim());
                            isRight = true;
                        }
                    }
                }
            }

            if (isRight)
            {
                foreach (DataRow tt in dt.Rows)
                {
                    var check = tt["unit_code"].ToString().Trim().ToUpper();
                    dt_id.Rows.Add(check.ToString().Trim());
                }

                d.Clear();
                d.Add("type", "id");
                d.Add("value", id.Text.Trim());
                ds = du.getDataSet("QueryResult", d, "tempTable", dt_id);
                GridView1.DataSource = ds.Tables[0];
                GridView1.DataBind();
            }
        }
        else
        {
            GridView1.DataBind();
        }

        if (ds.Tables.Count == 0)
        {
            this.idnone.Style.Value = "";
        }
        else
        {
            this.idnone.Style.Value = "display:none";
        }

        TabContainer1.ActiveTabIndex = 0;
    }