Beispiel #1
0
    // 用遞迴方式建立 Nodes
    private void AddNodes(ref TreeNode pNode, ref DataTable dt_Al_List, int up_al_sid)
    {
        DataRow[] dRow = dt_Al_List.Select("up_al_sid = " + up_al_sid.ToString());

        // 如果有資料,則建立子節點
        if (dRow.GetUpperBound(0) > -1)
        {
            TreeNode subNode;

            foreach (DataRow sRow in dRow)
            {
                subNode = new TreeNode();

                if (sRow[0].ToString() == lb_al_sid.Text)
                {
                    subNode.Select();
                }

                subNode.Text = sRow[2].ToString();
                subNode.Value = sRow[0].ToString();

                subNode.NavigateUrl = "3001.aspx?al_sid=" + sRow[0].ToString();
                subNode.Target = "_parent";
                subNode.ToolTip = sRow[3].ToString();
                pNode.ChildNodes.Add(subNode);

                AddNodes(ref subNode, ref dt_Al_List, int.Parse(sRow[0].ToString()));
            }
            dRow = null;
        }
    }
    private void BindTree()
    {
        //获取品牌
        string brandcondition = "";
        if (Request.QueryString["IsOpponent"] != null)
        {
            if (Request.QueryString["IsOpponent"] == "10")
                brandcondition = "IsOpponent IN (1,9)";
            else
                brandcondition = "IsOpponent=" + Request.QueryString["IsOpponent"];
        }
        else
        {
            if ((int)Session["OwnerType"] == 2) brandcondition = "IsOpponent='1'";
        }
        IList<PDT_Brand> _brands = PDT_BrandBLL.GetModelList(brandcondition);

        foreach (PDT_Brand brand in _brands)
        {
            TreeNode tn_brand = new TreeNode(brand.Name, brand.ID.ToString());
            tr_Product.Nodes.Add(tn_brand);

            string ConditionStr = "PDT_Product.State = 1 AND PDT_Product.ApproveFlag = 1 AND PDT_Product.Brand = " + brand.ID.ToString();

            if ((int)Session["OwnerType"] == 2)
            {
                ConditionStr += "  AND PDT_Product.OwnerType = 2 AND PDT_Product.OwnerClient =" + Session["OwnerClient"].ToString();
            }
            else if ((int)Session["OwnerType"] == 1)
            {
                ConditionStr += "  AND PDT_Product.OwnerType IN (1, 2) ";
            }

            if (Request.QueryString["ExtCondition"] != null)
            {
                ConditionStr += " AND (" + Request.QueryString["ExtCondition"].Replace("\"", "").Replace('~', '\'') + ")";
            }

            IList<PDT_Product> _products = PDT_ProductBLL.GetModelList(ConditionStr);
            foreach (PDT_Product product in _products)
            {
                TreeNode tn = new TreeNode();
                tn.Text = product.FactoryCode + "  " + product.FullName;
                tn.Value = product.ID.ToString();
                tn_brand.ChildNodes.Add(tn);

                if (tn.Value == ViewState["ID"].ToString())
                {
                    tn_brand.Expand();
                    tn.Select();
                    tbx_SelectedProductID.Text = tn.Value;
                    tbx_SelectedProductName.Text = tn.Text;
                }
            }

        }
    }
    private void BindTree()
    {
        //获取品牌
        string condition = "";
        if (Request.QueryString["IsOpponent"] != null)
            condition = "IsOpponent=" + Request.QueryString["IsOpponent"];

        IList<PDT_Brand> _brands = PDT_BrandBLL.GetModelList(condition);

        foreach (PDT_Brand brand in _brands)
        {
            TreeNode tn_brand = new TreeNode(brand.Name, brand.ID.ToString());
            tr_Product.Nodes.Add(tn_brand);

            IList<PDT_Classify> _classifys = new PDT_ClassifyBLL()._GetModelList("PDT_Classify.Brand=" + brand.ID.ToString());
            foreach (PDT_Classify classify in _classifys)
            {
                TreeNode tn_classify = new TreeNode(classify.Name, classify.ID.ToString());
                tn_brand.ChildNodes.Add(tn_classify);

                IList<PDT_Product> _products = new PDT_ProductBLL()._GetModelList("PDT_Product.State = 1 AND PDT_Product.Classify=" + classify.ID.ToString());
                foreach (PDT_Product product in _products)
                {
                    TreeNode tn = new TreeNode();
                    tn.Text = product.Code + "  " + product.FullName;
                    tn.Value = product.Code;
                    tn_classify.ChildNodes.Add(tn);

                    if (tn.Value == ViewState["ERPCode"].ToString())
                    {
                        tn_classify.Expand();
                        tn.Select();
                        tbx_SelectedProductCode.Text = tn.Value;
                        tbx_SelectedProductName.Text = tn.Text;
                    }
                }

            }
        }
    }
    /// <summary>
    /// Recursively adds nodes to the treeview menu starting at a given set of peers of a parent node.
    /// </summary>
    /// <param name="nodes">The root treenode collection to which to add child cnodes</param>
    /// <param name="parentCodexRecordId">The parent node record's ID, used to fetch the children</param>
    private void BuildCodexMenu( TreeNodeCollection nodes, int parentCodexRecordId )
    {
        CodexRecordList list = parentCodexRecordId > 0 ? CodexRecordList.GetCodexRecordList( parentCodexRecordId ) : CodexRecordList.GetCodexRecordList();

        //no child nodes (parent will always be included), exit function
        if ( list.Count < 2 ) return;

        foreach ( CodexRecord record in list )
        {
            if ( record.ID == parentCodexRecordId || ( parentCodexRecordId == 0 && record.ParentCodexRecordID != 0 ) ) continue;

            TreeNode node = new TreeNode( record.Title, record.ID.ToString() );

            // automatically select the first root node
            if ( record.ParentCodexRecordID == 0 && CodexMenu.SelectedNode == null ) node.Select();

            nodes.Add( node );
            node.ToggleExpandState();

            BuildCodexMenu( node.ChildNodes, record.ID );
        }
    }
Beispiel #5
0
    // 用遞迴方式建立 Nodes
    private void AddNodes(ref TreeNode pNode, string up_fl_path)
    {
        string furl = "", ftext;

        // 如果有資料,則建立子節點
        if (Directory.Exists(up_fl_path))
        {
            TreeNode subNode;

            foreach (string fpath in Directory.GetDirectories(up_fl_path))
            {
                furl = fpath.Replace(lb_path.Text, "").Replace("\\", "/");

                // _thumb 為縮圖存放目錄,不顯示
                if (! furl.Contains("_thumb"))
                {
                    subNode = new TreeNode();

                    if (lb_fl_url.Text == (Album.Root + furl))
                    {
                        subNode.Select();
                    }

                    ftext = fpath.Replace(up_fl_path, "").Replace("\\", "");

                    subNode.Text = ftext;
                    subNode.Value = ftext;

                    subNode.NavigateUrl = "3002.aspx?fl_url=" + Server.UrlEncode(dcode.EnCode(Album.Root + furl));
                    subNode.Target = "_parent";
                    subNode.ToolTip = furl;
                    pNode.ChildNodes.Add(subNode);

                    AddNodes(ref subNode, fpath);
                }
            }
        }
    }
    private void BindTree()
    {
        //获取品牌
        string condition = "";
        if (Request.QueryString["IsOpponent"] != null)
            condition = "IsOpponent=" + Request.QueryString["IsOpponent"];

        IList<PDT_Brand> _brands = PDT_BrandBLL.GetModelList(condition);

        dl_brand.DataSource = _brands;
        dl_brand.DataBind();
        dl_brand.Items.Insert(0, new ListItem("请选择", "0"));
        dl_brand_SelectedIndexChanged(null, null);

        foreach (PDT_Brand brand in _brands)
        {
            TreeNode tn_brand = new TreeNode(brand.Name, brand.ID.ToString());
            tr_Product.Nodes.Add(tn_brand);
            IList<PDT_Classify> _classifys = new PDT_ClassifyBLL()._GetModelList("PDT_Classify.Brand=" + brand.ID.ToString());
            foreach (PDT_Classify classify in _classifys)
            {
                TreeNode tn_classify = new TreeNode(classify.Name, classify.ID.ToString());
                tn_brand.ChildNodes.Add(tn_classify);

                string ConditionStr = "PDT_Product.State = 1 AND PDT_Product.Classify=" + classify.ID.ToString()+"and pdt_product.approveflag=1";
                if (Request.QueryString["ExtCondition"] != null)
                {
                    ConditionStr += " AND (" + Request.QueryString["ExtCondition"].Replace("\"", "").Replace('~', '\'') + ")";
                }

                IList<PDT_Product> _products = PDT_ProductBLL.GetModelList(ConditionStr);
                foreach (PDT_Product product in _products)
                {
                    TreeNode tn = new TreeNode();
                    tn.Text = product.Code + "  " + product.FullName;
                    tn.Value = product.ID.ToString();
                    tn_classify.ChildNodes.Add(tn);

                    if (tn.Value == ViewState["ID"].ToString())
                    {
                        tn_classify.Expand();
                        tn.Select();
                        tbx_SelectedProductID.Text = tn.Value;
                        tbx_SelectedProductName.Text = tn.Text;
                    }
                }

            }
        }
    }
Beispiel #7
0
    // 建立 TreeView
    private void BuildTreeView()
    {
        TreeNode RootNode = new TreeNode();         //根節點

        RootNode.Text = "根目錄";
        RootNode.Value = "0";
        RootNode.ToolTip = "";
        RootNode.NavigateUrl = "3002.aspx?fl_url=" + Server.UrlEncode(dcode.EnCode(Album.Root));
        RootNode.Target = "_parent";

        if (lb_fl_url.Text == Album.Root)
            RootNode.Select();

        tv_Al_List.Nodes.Clear();
        tv_Al_List.Nodes.Add(RootNode);
        tv_Al_List.ExpandAll();

        AddNodes(ref RootNode, lb_path.Text);
    }
    protected void botSaveModelo_Click(object sender, EventArgs e)
    {
        // parte geral
        ModeloCompetencias selModelo;
        selModelo = (ModeloCompetencias)Session["selectedObject"];
        selModelo.PublicName = this.txtNome.Text;
        selModelo.Name = this.txtNomeBreve.Text;
        selModelo.Description = Context.Server.HtmlEncode(this.txtDescricao.Text);
        selModelo.IntroText = Context.Server.HtmlEncode(this.txtIntroducao.Text);
        selModelo.CommentsText = Context.Server.HtmlEncode(this.txtIntroducaoComments.Text);
        selModelo.AllowRespondentComments = this.chkComments.Checked;
        selModelo.Scale = this.txtModeloEscala.Text;
        selModelo.ScaleDesc = Context.Server.HtmlEncode(this.txtModeloEscalaDesc.Text);
        selModelo.ModelType = this.txtTipoModelo.Text;
        selModelo.NR = chkNR_Modelo.Checked;
        // parte específica

        // grava
        selModelo.updateDBModelo("JC");
        String mode="";
        if (Session["mode"] != null)
            mode = (String)Session["mode"];

        modelos = (SortedList<int, ModeloCompetencias>)Session["modelos"];

        if (mode == "ADD_NEW")
        {
            TreeNode n1 = new TreeNode(selModelo.Name, selModelo.ModeloID.ToString());
            ModelTree.Nodes.Add(n1);
            modelos.Add(selModelo.ModeloID, selModelo);
            Session.Remove("mode");
            n1.Select();
            //n1.Expand();
        }
        else if (mode.StartsWith("DUPLICATE"))
        {
            //String[] dup = mode.Split(';');
            //String modelToDuplicate = dup[1];
            //ModeloCompetencias.duplicateModelo(int.Parse(modelToDuplicate), selModelo.ModeloID);

            TreeNode n1 = new TreeNode(selModelo.Name, selModelo.ModeloID.ToString());
            ModelTree.Nodes.Add(n1);
            modelos.Add(selModelo.ModeloID, selModelo);
            Session.Remove("mode");
            n1.PopulateOnDemand = true;
            n1.Select();
        }
        else
        {
            // actualiza a árvore de menus
            TreeNode theNode = ModelTree.FindNode(selModelo.ModeloID.ToString());
            theNode.Text = selModelo.Name;
            modelos[selModelo.ModeloID] = selModelo;
        }
        Session["modelos"] = modelos;
        Session["currModelo"] = currModelo;
        Session["selectedObject"] = currModelo;

        if (currModelo.ScaleDesc == "RANDOM")
        {
            currModelo.randomPerguntas();
            currModelo.ScaleDesc = "RANDOMIZED";
            currModelo.updateDBModelo("JC");
        }
    }
Beispiel #9
0
        //int CompareFolder(SPFolder f1, SPFolder f2)
        //{
        //    return f1.Name.CompareTo(f2.Name);
        //}
        //�����ļ�����
        void buildSub(string pageUrl, string webUrl , string currentFolderUrl ,  SPFolder root, TreeNodeCollection nodes)
        {
            if (root.SubFolders.Count == 0) return;

            IList<SPFolder> sortedFolders = this.GetSortedSubFolders(root);

            foreach (SPFolder f in sortedFolders )
            {
                //if (  f.Name.ToLower() == "forms") continue;

                if (IsHiddenFolder(f)) continue;

                string folderUrl = webUrl + f.Url;

                TreeNode n = new TreeNode();

               // string url = webUrl + pageUrl + "?RootFolder=" + folderUrl ;// + Page.Server.UrlEncode(folderUrl);

               // n.NavigateUrl = "javascript:SubmitFormPost( '"+pageUrl+"' + encodeURIComponent('" + f.Url + "') );"; //EnterFolder and SubmitFormPost��ϵͳjs

                n.NavigateUrl = pageUrl + Page.Server.UrlEncode(folderUrl);

                //n.Expanded = Expanded ;
                n.ImageUrl = "/_layouts/images/folder.gif";
                nodes.Add(n);

                if (String.Compare(currentFolderUrl, folderUrl, true) == 0) //չ�����и�
                {
                    n.Expand();
                    TreeNode temp = n.Parent;
                    while (temp != null)
                    {
                        temp.Expand();
                        temp = temp.Parent;
                    }
                    n.Select();
                    //n.Text = "<b>" + f.Name + "</b>(" + f.Files.Count + ")";

                    n.Text = "<b>" + f.Name + "</b>";
                }
                else
                {
                    //n.Collapse();
                    n.Text = f.Name ;
                }

                //n.Text = "<a href='"+url+"' onclick=\"javascript:EnterFolder('" + url + "');return false;\">" + n.Text + "<a>";

                buildSub(pageUrl, webUrl , currentFolderUrl , f, n.ChildNodes);
            }
        }
 private void showNode(TreeNode treeNode)
 {
     treeNode.Select();
     while (treeNode.Parent != null)
     {
         treeNode = treeNode.Parent;
         treeNode.Expand();
     }
 }
 protected void treeCategory_NodeExpanded(object sender, TreeNodeEventArgs e)
 {
     if (e.Node.ChildNodes.Count > 0 && e.Node.ChildNodes[0].Value == "NULL_NODE") {
         e.Node.ChildNodes.RemoveAt(0);
         if (e.Node.Depth == 0) {
             int catalogId = int.Parse(e.Node.Value);
             var catalog = UCommerce.EntitiesV2.ProductCatalog.All().SingleOrDefault(cata => cata.ProductCatalogId == catalogId);
             if (catalog != null) {
                 foreach (var category in catalog.Categories.Where(cate => cate.ParentCategory == null && !cate.Deleted)) {
                     TreeNode catNode = new TreeNode(category.Name, category.CategoryId.ToString());
                     catNode.ImageUrl = "/umbraco/images/umbraco/folder.gif";
                     e.Node.ChildNodes.Add(catNode);
                     if (category.Categories.Count > 0) {
                         catNode.ChildNodes.Add(new TreeNode("", "NULL_NODE"));
                     }
                     if(catNode.Value == _umbracoValue)
                         catNode.Select();
                 }
             }
         }
         if(e.Node.Depth > 0) {
             int categoryId = int.Parse(e.Node.Value);
             var category = UCommerce.EntitiesV2.Category.All().SingleOrDefault(cate => cate.CategoryId == categoryId);
             if(category != null) {
                 foreach(var subCat in category.Categories) {
                     TreeNode catNode = new TreeNode(subCat.Name, subCat.CategoryId.ToString());
                     catNode.ImageUrl = "/umbraco/images/umbraco/folder.gif";
                     e.Node.ChildNodes.Add(catNode);
                     if(subCat.Categories.Count > 0) {
                         catNode.ChildNodes.Add(new TreeNode("", "NULL_NODE"));
                     }
                     if(catNode.Value == _umbracoValue)
                         catNode.Select();
                 }
             }
         }
     }
 }
Beispiel #12
0
    // 建立 TreeView
    private void BuildTreeView()
    {
        TreeNode RootNode = new TreeNode();         //根節點

        RootNode.Text = "根目錄";
        RootNode.Value = "0";
        RootNode.ToolTip = "";
        RootNode.NavigateUrl = "3001.aspx?al_sid=0";
        RootNode.Target = "_parent";

        if (lb_al_sid.Text == "0")
            RootNode.Select();

        tv_Al_List.Nodes.Clear();
        tv_Al_List.Nodes.Add(RootNode);
        tv_Al_List.ExpandAll();

        using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
        {
            Sql_Conn.Open();

            string SqlString = "";

            SqlString = "Select al_sid, up_al_sid, al_name, al_desc From Al_List Order by up_al_sid, al_sort";

            using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
            {
                using (SqlDataAdapter Sql_Adapter = new SqlDataAdapter(Sql_Command))
                {
                    DataTable dt_Al_List = new DataTable();

                    Sql_Adapter.Fill(dt_Al_List);

                    // 用遞迴方式建立 Nodes
                    AddNodes(ref RootNode, ref dt_Al_List, 0);

                    dt_Al_List.Clear();
                    dt_Al_List.Dispose();
                }
            }
            Sql_Conn.Close();
        }
    }
        protected void Page_Load( object sender, EventArgs e )
        {
            Response.Cache.SetCacheability( HttpCacheability.NoCache );

            ScriptsManager.RegisterJQuery(Page);

            if( !IsPostBack )
            {
                TreeNode root = new TreeNode( "Библиотека документов", "0" );
                root.SelectAction = TreeNodeSelectAction.SelectExpand;
                root.ImageUrl = "~/Controls/FileManager/root.gif";
                _treeView.Nodes.Add( root );

                using (var dc = new DCFactory<CmsDataContext>())
                {
                    AddChildren( root, dc.DataContext.Folders.Where( f => f.ParentID == null ).OrderBy( f => f.FolderName ).ToArray() );
                }

                _treeView.CollapseAll();
                root.Expand();
                root.Select();
            }
        }
    protected void botSavePratica_Click(object sender, EventArgs e)
    {
        // parte geral
        Pratica selPratica;
        selPratica = (Pratica)Session["selectedObject"];
        selPratica.PublicName = this.txtNome.Text;
        selPratica.Name = this.txtNomeBreve.Text;

        selPratica.Description = Context.Server.HtmlEncode(this.txtDescricao.Text);
        selPratica.IntroText = Context.Server.HtmlEncode(this.txtIntroducao.Text);
        selPratica.CommentsText = Context.Server.HtmlEncode(this.txtIntroducaoComments.Text);
        selPratica.AllowRespondentComments = this.chkComments.Checked;

        // parte específica
        selPratica.Criticalidade = this.chkCriticPratica.Checked;
        selPratica.CriticalidadeScale = Context.Server.HtmlEncode(this.txtCriticPratEscala.Text);
        selPratica.CriticalidadeText = Context.Server.HtmlEncode(this.txtCriticPratDescrEscala.Text);
        selPratica.NR = chkNR.Checked;

        // grava na base de dados
        selPratica.updateDBPratica("JC");
        String mode = "";
        if (Session["mode"] != null)
            mode = (String)Session["mode"];

        modelos = (SortedList<int, ModeloCompetencias>)Session["modelos"];
        Competencia currCompetencia = selPratica.Competencia;
        FamiliaCompetencias currFamilia = currCompetencia.Familia;

        currModelo = modelos[currFamilia.Modelo.ModeloID];
        // actualiza a árvore de menus
        if (mode == "ADD_NEW")
        {
            TreeNode n1 = new TreeNode(selPratica.Name, selPratica.PraticaID.ToString());
            ModelTree.FindNode(currModelo.ModeloID.ToString() + "|"
                                + currFamilia.FamiliaID.ToString() + "|"
                                + currCompetencia.CompetenciaID.ToString()).ChildNodes.Add(n1);
            currCompetencia.addPratica(selPratica);
            currFamilia.updateCompetencia(currCompetencia);
            currModelo.updateFamilia(currFamilia);
            Session.Remove("mode");
            n1.Select();
            //n1.Expand();

        }
        else
        {
            TreeNode theNode = ModelTree.FindNode(currModelo.ModeloID.ToString() + "|"
                                                    + currFamilia.FamiliaID.ToString() + "|"
                                                    + currCompetencia.CompetenciaID.ToString() + "|"
                                                    + selPratica.PraticaID.ToString());
            theNode.Text = selPratica.Name;
            currCompetencia.updatePratica(selPratica); // actualiza a lista de pratica da competência
            currFamilia.updateCompetencia(currCompetencia); // actualiza a lista de competencias na família
            currModelo.updateFamilia(currFamilia); // actualiza a lista de famílias no modelo
        }

        Session["modelos"] = modelos;
        Session["currModelo"] = currModelo;
        Session["selectedObject"] = selPratica;
    }
    protected void botSavePergunta_Click(object sender, EventArgs e)
    {
        // parte geral

        // parte específica
        Pergunta selPergunta;
        selPergunta = (Pergunta)Session["selectedObject"];
        selPergunta.Name = this.txtNomePergunta.Text;
        selPergunta.TextoBase = this.txtTextoPergunta.Text;
        selPergunta.MainSortIndex = this.txtGlobalIndex.Text == "" ? -1 : int.Parse(this.txtGlobalIndex.Text);
        selPergunta.tipoPergunta = this.txtTipoPergunta.Text == "" ? null : this.txtTipoPergunta.Text;
        selPergunta.valor = this.txtValor.Text == "" ? -1 : int.Parse(this.txtValor.Text);
        selPergunta.ponderador = this.txtPonderador.Text == "" ? -1 : float.Parse(this.txtPonderador.Text);
        selPergunta.Codificacao = this.txtCodificacao.Text == "" ? null : this.txtCodificacao.Text;

        // grava na base de dados
        selPergunta.updateDBPergunta("JC");

        String mode = "";
        if (Session["mode"] != null)
            mode = (String)Session["mode"];

        modelos = (SortedList<int, ModeloCompetencias>)Session["modelos"];
        Pratica currPratica = selPergunta.Pratica;
        Competencia currCompetencia = currPratica.Competencia;
        FamiliaCompetencias currFamilia = currCompetencia.Familia;
        currModelo = modelos[currFamilia.Modelo.ModeloID];
        // actualiza a árvore de menus
        if (mode == "ADD_NEW")
        {
            TreeNode n1 = new TreeNode(selPergunta.Name, selPergunta.PerguntaID.ToString());
            ModelTree.FindNode(currModelo.ModeloID.ToString() + "|"
                                + currFamilia.FamiliaID.ToString() + "|"
                                + currCompetencia.CompetenciaID.ToString() + "|"
                                + currPratica.PraticaID.ToString()).ChildNodes.Add(n1);
            currPratica.addPergunta(selPergunta);
            currCompetencia.updatePratica(currPratica);
            currFamilia.updateCompetencia(currCompetencia);
            currModelo.updateFamilia(currFamilia);
            Session.Remove("mode");
            n1.Select();
            //n1.Expand();
        }
        else
        {
            TreeNode theNode = ModelTree.FindNode(currModelo.ModeloID.ToString() + "|"
                                                + currFamilia.FamiliaID.ToString() + "|"
                                                + currCompetencia.CompetenciaID.ToString() + "|"
                                                + currPratica.PraticaID.ToString() + "|"
                                                + selPergunta.PerguntaID.ToString());
            theNode.Text = selPergunta.Name;
            currPratica.updatePergunta(selPergunta);
            currCompetencia.updatePratica(currPratica); // actualiza a lista de pratica da competência
            currFamilia.updateCompetencia(currCompetencia); // actualiza a lista de competencias na família
            currModelo.updateFamilia(currFamilia); // actualiza a lista de famílias no modelo
        }
        Session["modelos"] = modelos;
        Session["currModelo"] = currModelo;
        Session["selectedObject"] = selPergunta;

        // actualiza o preview da pegunta

        this.txtNomePergunta.Text = Context.Server.HtmlDecode(selPergunta.Name);
        this.txtTextoPergunta.Text = Context.Server.HtmlDecode(selPergunta.TextoBase);

        Pessoa p1 = new Pessoa();
        p1.NomeProprio = "Joana";
        p1.NomesMeio = "dos Santos";
        p1.Apelido = "Marques";
        p1.Sexo = "F";
        p1.Email = "aaa";

        Pessoa p2 = new Pessoa();
        p2.NomeProprio = "Vasco";
        p2.NomesMeio = "Manuel";
        p2.Apelido = "Carvalho";
        p2.Sexo = "M";
        p2.Email = "bbb";

        Pessoa p3 = new Pessoa();
        p3.NomeProprio = "Marco";
        p3.NomesMeio = "António";
        p3.Apelido = "Curto";
        p3.Sexo = "M";
        p3.Email = "ccc";

        Pergunta perg = new Pergunta(selPergunta.TextoBase);
        perg.setupPergunta(p1, p1,false);
        this.lblAutoavaliacao.Text = "<p>" + Context.Server.HtmlDecode(perg.GetPerguntaText()) + "</p>";
        Pessoa[] grupo = { p1, p3 };

        perg.setupPergunta(p2, grupo, false);
        this.lblGrupo.Text = "<p>" + Context.Server.HtmlDecode(perg.GetPerguntaText()) + "</p>";

        perg.setupPergunta(p2, p1, false);
        this.lblJoana.Text = "<p>" + Context.Server.HtmlDecode(perg.GetPerguntaText()) + "</p>";

        perg.setupPergunta(p3, p2, false);
        this.lblVasco.Text = "<p>" + Context.Server.HtmlDecode(perg.GetPerguntaText()) + "</p>";
    }
        protected void treeProduct_NodeExpanded(object sender, TreeNodeEventArgs tnea)
        {
            TreeNode n = tnea.Node;
            if (n.ChildNodes[0].Value == "NULL_NODE") {
                n.ChildNodes.RemoveAt(0);
                string[] val = n.Value.Split('|');
                if (val[0] == catalogPrefix) {
                    int catalogId = int.Parse(val[1]);
                    var catalog = UCommerce.EntitiesV2.ProductCatalog.All().SingleOrDefault(cata => cata.ProductCatalogId == catalogId);
                    if (catalog != null) {
                        foreach (var category in catalog.Categories.Where(cate => cate.ParentCategory == null)) {
                            TreeNode catNode = new TreeNode(category.Name, categoryPrefix + "|" + category.CategoryId.ToString())
                                               	{ImageUrl = "/umbraco/images/umbraco/folder.gif"};
                            if (category.Categories.Count > 0 || category.Products.Count() > 0) {
                                catNode.ChildNodes.Add(new TreeNode("", "NULL_NODE"));
                            }
                            n.ChildNodes.Add(catNode);
                        }
                    }
                }
                else if (val[0] == categoryPrefix) {
                    int categoryId = int.Parse(val[1]);
                    var category = UCommerce.EntitiesV2.Category.All().SingleOrDefault(cate => cate.CategoryId == categoryId);
                    if (category != null) {
                        foreach (var subCat in category.Categories) {
                            TreeNode catNode = new TreeNode(subCat.Name, categoryPrefix + "|" + subCat.CategoryId.ToString())
                                               	{ImageUrl = "/umbraco/images/umbraco/folder.gif"};
                            if (subCat.Categories.Count > 0 || subCat.Products.Count() > 0) {
                                catNode.ChildNodes.Add(new TreeNode("", "NULL_NODE"));
                            }
                            n.ChildNodes.Add(catNode);
                        }
                        foreach (var product in category.Products) {
                            TreeNode prodNode = new TreeNode(product.Name, productPrefix + "|" + product.Sku)
                                                    {ImageUrl = "/umbraco/images/umbraco/package.gif"};
                            n.ChildNodes.Add(prodNode);
                            if (product.Sku == _umbracoValue) {
                                prodNode.Select();
                            }
                        }

                    }
                }
            }
        }
Beispiel #17
0
 private static bool SelectTreeNodeByNodeValue(TreeView treeView, TreeNode node, string nodeValue)
 {
     if (node.Value.Equals(nodeValue)) {
         treeView.CollapseAll();
         TreeNode parentNode = node.Parent;
         while (parentNode != null) {
             parentNode.Expand();
             parentNode = parentNode.Parent;
         }
         node.Select();
         return true;
     } else {
         foreach (TreeNode childNode in node.ChildNodes) {
             if (SelectTreeNodeByNodeValue(treeView, childNode, nodeValue)) {
                 return true;
             }
         }
         return false;
     }
 }
    private void GenareateSubMenu(DataTable dtMenu, int RootMenuIndex, TreeNodeCollection TNC, int SuperID)
    {
        foreach (DataRow row in dtMenu.Select("SuperID=" + SuperID.ToString()))
        {
            int menuid = (int)row["ID"];
            TreeNode tn = new TreeNode();
            tn.Text = (string)row["Name"];
            if (dtMenu.Select("SuperID=" + menuid.ToString()).Length == 0)
            {
                tn.Value = RootMenuIndex.ToString() + "|" + menuid.ToString() + "|" + row["Remark"].ToString();
                tn.NavigateUrl = "~/SubModule/switch.aspx?Action=1&Module=" + menuid.ToString() + "&ActiveRootNode=" + RootMenuIndex.ToString();
                tn.Target = "fr_Main";
            }
            else
            {
                tn.Value = RootMenuIndex.ToString() + "|" + menuid.ToString();
                tn.SelectAction = TreeNodeSelectAction.Expand;
            }

            if (Session["ActiveModule"] != null && menuid == (int)Session["ActiveModule"])
            {
                tn.Select();
                //tn.Text = "<span style='color:red'>" + tn.Text + "</span>";
            }

            TNC.Add(tn);

            //if (dtMenu.Select("SuperID=" + menuid.ToString()).Length > 0 &&
            //    Session["ActiveRootNode"] != null && (int)Session["ActiveRootNode"] == RootMenuIndex)
            {
                //同主模块级下的树形先展开
                GenareateSubMenu(dtMenu, RootMenuIndex, tn.ChildNodes, menuid);
                tn.Collapse();
            }

            #region 获取当前已选择中节点的根节点,以便展开
            if (Session["ActiveModule"] != null && menuid == (int)Session["ActiveModule"])
            {
                TreeNode node = tn;
                while (node.Parent != null)
                {
                    node = node.Parent;
                }
                ViewState["CurrentRootNode"] = node.ValuePath;
            }
            #endregion
        }
    }
		void HandleSelectEvent (TreeNode node)
		{
			switch (node.SelectAction) {
				case TreeNodeSelectAction.Select:
					node.Select ();
					break;
				case TreeNodeSelectAction.Expand:
					node.Expand ();
					break;
				case TreeNodeSelectAction.SelectExpand:
					node.Select ();
					node.Expand ();
					break;
			}
		}
    protected void botSaveFamilia_Click(object sender, EventArgs e)
    {
        // parte geral
        FamiliaCompetencias selFamilia;
        selFamilia = (FamiliaCompetencias)Session["selectedObject"];
        selFamilia.PublicName = this.txtNome.Text;
        selFamilia.Name = this.txtNomeBreve.Text;
        selFamilia.Description = Context.Server.HtmlEncode(this.txtDescricao.Text);
        selFamilia.IntroText = Context.Server.HtmlEncode(this.txtIntroducao.Text);
        selFamilia.CommentsText = Context.Server.HtmlEncode(this.txtIntroducaoComments.Text);
        selFamilia.AllowRespondentComments = this.chkComments.Checked;

        // parte específica

        // grava na base de dados
        selFamilia.updateDBFamilia("JC");
        String mode = "";
        if (Session["mode"] != null)
            mode = (String)Session["mode"];

        modelos = (SortedList<int, ModeloCompetencias>)Session["modelos"];
        currModelo = modelos[selFamilia.Modelo.ModeloID];

        if (mode == "ADD_NEW")
        {
            TreeNode n1 = new TreeNode(selFamilia.Name, selFamilia.FamiliaID.ToString());
            ModelTree.FindNode(selFamilia.Modelo.ModeloID.ToString()).ChildNodes.Add(n1);
            currModelo.addFamilia(selFamilia);
            Session.Remove("mode");
            n1.Select();
            //n1.Expand();
        }
        else
        {
            // actualiza a árvore de menus

            TreeNode theNode = ModelTree.FindNode(selFamilia.Modelo.ModeloID.ToString() + "|" + selFamilia.FamiliaID.ToString());
            theNode.Text = selFamilia.Name;
            currModelo.updateFamilia(selFamilia);
        }

        Session["modelos"] = modelos;
        Session["currModelo"] = currModelo;
        Session["selectedObject"] = selFamilia;
    }