Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PostBLL postBLL = new PostBLL();
                IList <RailExam.Model.Post> postList = postBLL.GetPosts();

                string   strID  = Request.QueryString["id"];
                string[] strIDS = { };
                if (!string.IsNullOrEmpty(strID))
                {
                    strIDS = strID.Split(',');
                }

                RailExam.BLL.PostBLL PostBLL   = new RailExam.BLL.PostBLL();
                IList <Post>         postsList = PostBLL.GetPosts();

                if (postsList.Count > 0)
                {
                    TreeViewNode tvn = null;

                    foreach (Post post in postsList)
                    {
                        tvn         = new TreeViewNode();
                        tvn.ID      = post.PostId.ToString();
                        tvn.Value   = post.PostId.ToString();
                        tvn.Text    = post.PostName;
                        tvn.ToolTip = post.PostName;

                        if (post.PostLevel == 3)
                        {
                            tvn.ShowCheckBox = true;
                        }


                        foreach (string strOrgID in strIDS)
                        {
                            if (strOrgID == post.PostId.ToString() && tvn.ShowCheckBox)
                            {
                                tvn.Checked = true;
                            }
                        }

                        if (post.ParentId == 0)
                        {
                            tvPost.Nodes.Add(tvn);
                        }
                        else
                        {
                            try
                            {
                                tvPost.FindNodeById(post.ParentId.ToString()).Nodes.Add(tvn);
                            }
                            catch
                            {
                                tvPost.Nodes.Clear();
                                SessionSet.PageMessage = "Êý¾Ý´íÎó£¡";
                                return;
                            }
                        }
                    }
                }

                tvPost.DataBind();
            }
        }
        private void initJianZhiCMB(DataSet ds, string could_Post_ID_str)
        {
            string[]  postIDs   = could_Post_ID_str.Split(',');
            string    postNames = string.Empty;
            string    domStr    = "var jzHTMLText=\"兼职1 : <select id='cmbJianZhi1' onchange='changeJianZhi1();'" + (isReadOnly ? " disabled='disabled' " : "") + "><option value='-1' >--请选择--</option>";
            Hashtable hs        = new Hashtable();

            for (int i = 0; i < postIDs.Length; i++)
            {
                if (string.IsNullOrEmpty(postIDs[i]))
                {
                    continue;
                }
                RailExam.BLL.PostBLL PostBLL = new RailExam.BLL.PostBLL();
                int postID = 0;
                int.TryParse(postIDs[i], out postID);

                RailExam.Model.Post post = PostBLL.GetPost(postID);
                if (post == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(postNames))
                {
                    postNames += post.PostName;
                }
                else
                {
                    postNames += ',' + post.PostName;
                }
                domStr += "<option value='" + postIDs[i] + "' ";
                if (postIDs[i] == getEntityString(ds.Tables[0].Rows[0]["SECOND_POST_ID"]))
                {
                    domStr += " selected='selected'";
                }
                if (isReadOnly)
                {
                    domStr += " disabled='disabled' ";
                }

                domStr += ">" + post.PostName + "</option>";

                hs.Add(postIDs[i], post.PostName);
            }
            domStr += "</select>&nbsp;&nbsp;&nbsp;&nbsp;兼职2 : <select id='cmbJianZhi2' onchange='changeJianZhi2();'" + (isReadOnly ? " disabled='disabled' " : "") + "><option value='-1' >--请选择--</option>";
            for (int i = 0; i < postIDs.Length; i++)
            {
                if (string.IsNullOrEmpty(postIDs[i]))
                {
                    continue;
                }

                domStr += "<option value='" + postIDs[i] + "' ";
                if (postIDs[i] == getEntityString(ds.Tables[0].Rows[0]["THIRD_POST_ID"]))
                {
                    domStr += " selected='selected'";
                }
                domStr += ">" + hs[postIDs[i]] + "</option>";
            }
            domStr += "\";document.getElementById('divJianZhi1').innerHTML=jzHTMLText;";
            this.ClientScript.RegisterStartupScript(this.GetType(), " ", "<script language='javascript'>" + domStr + "</script>");
            txtCOULD_POST_Name.Text = postNames;
        }
Exemplo n.º 3
0
        private void BindPostTree()
        {
            string strID       = Request.QueryString["postId"];
            string selectedIds = Request.QueryString["ids"].ToString();

            //string[] strIDS = { };
            //if (!string.IsNullOrEmpty(strID))
            //{
            //    strIDS = strID.Split(',');
            //}
            int postID = 0;

            int.TryParse(strID, out postID);

            RailExam.BLL.PostBLL PostBLL = new RailExam.BLL.PostBLL();

            Post post = PostBLL.GetPost(postID);

            string[] strIDs = { };
            if (!string.IsNullOrEmpty(post.PromotionPostID))
            {
                strIDs = post.PromotionPostID.Split(',');
            }

            TreeViewNode tvn = null;

            foreach (string strID2 in strIDs)
            {
                int.TryParse(strID2, out postID);
                Post post2 = PostBLL.GetPost(postID);
                tvn              = new TreeViewNode();
                tvn.ID           = post2.PostId.ToString();
                tvn.Value        = post2.PostId.ToString();
                tvn.Text         = post2.PostName;
                tvn.ToolTip      = post2.PostName;
                tvn.ShowCheckBox = true;
                if (selectedIds.Contains(post2.PostId.ToString()))
                {
                    tvn.Checked = true;
                }
                tvPost.Nodes.Add(tvn);
            }

            //if (postsList.Count > 0)
            //{
            //    TreeViewNode tvn = null;

            //    foreach (Post post in postsList)
            //    {
            //        post.PromotionPostID
            //        tvn = new TreeViewNode();
            //        tvn.ID = post.PostId.ToString();
            //        tvn.Value = post.PostId.ToString();
            //        tvn.Text = post.PostName;
            //        tvn.ToolTip = post.PostName;


            //        if (postsList1.Count == 0)
            //        {
            //            tvn.ShowCheckBox = true;
            //        }


            //        foreach (string strOrgID in strIDS)
            //        {
            //            if (strOrgID == post.PostId.ToString() && tvn.ShowCheckBox)
            //                tvn.Checked = true;
            //        }

            //        if (post.ParentId == 0)
            //        {
            //            tvPost.Nodes.Add(tvn);
            //        }
            //        else
            //        {
            //            try
            //            {
            //                tvPost.FindNodeById(post.ParentId.ToString()).Nodes.Add(tvn);
            //            }
            //            catch
            //            {
            //                tvPost.Nodes.Clear();
            //                SessionSet.PageMessage = "数据错误!";
            //                return;
            //            }
            //        }
            //    }
            //}

            tvPost.DataBind();
            //tvPost.ExpandAll();
        }