예제 #1
0
    protected void updateSpecialFields()
    {
        object theObject;

        if (Session["selectedObject"] == null)
        {
            this.commonDataFieldsTable.Visible = false;
            return;
        }

        commonDataFieldsTable.Visible = true;

        theObject = Session["selectedObject"];

        if (theObject.GetType() == typeof(ModeloCompetencias))
        {
            ModeloCompetencias selObject;
            selObject = (ModeloCompetencias)Session["selectedObject"];
            txtModeloEscala.Text = selObject.Scale;
            txtModeloEscalaDesc.Text = Server.HtmlDecode(selObject.ScaleDesc);
            txtTipoModelo.Text = selObject.ModelType;
            this.chkNR_Modelo.Checked = selObject.NR == null ? false : selObject.NR;
        }
        else if (theObject.GetType() == typeof(FamiliaCompetencias))
        {

        }
        else if (theObject.GetType() == typeof(Competencia))
        {

            Competencia selObject;
            selObject = (Competencia)Session["selectedObject"];
            this.txtCriticCompEscala.Text = Server.HtmlDecode(selObject.CriticalidadeScale);
            this.txtCriticCompDescrEscala.Text = Server.HtmlDecode(selObject.CriticalidadeText);
            this.chkCriticCompetencia.Checked = selObject.Criticalidade;
            this.txtType.Text = selObject.Type;
            this.chkNR_Criticalidade.Checked = selObject.NR == null ? false : selObject.NR;
            this.chkOpcional.Checked = selObject.Opcional == null ? false : selObject.Opcional;
        }
        else if (theObject.GetType() == typeof(Pratica))
        {

            Pratica selObject;
            selObject = (Pratica)Session["selectedObject"];
            this.txtCriticPratEscala.Text = Server.HtmlDecode(selObject.CriticalidadeScale);
            this.txtCriticPratDescrEscala.Text = Server.HtmlDecode(selObject.CriticalidadeText);
            this.chkCriticPratica.Checked = selObject.Criticalidade;
            this.chkNR.Checked = selObject.NR;

        }
        else if (theObject.GetType() == typeof(Pergunta))
        {
            commonDataFieldsTable.Visible = false;
            Pergunta selObject;
            selObject = (Pergunta)Session["selectedObject"];

            this.txtNomePergunta.Text = selObject.Name;
            this.txtTextoPergunta.Text = selObject.TextoBase;
            this.txtGlobalIndex.Text = selObject.MainSortIndex.ToString();
            this.txtTipoPergunta.Text = selObject.tipoPergunta;
            this.txtValor.Text = selObject.valor == 0 ? "-1" :  selObject.valor.ToString();
            this.txtPonderador.Text = selObject.ponderador == 0 ? "-1" : selObject.ponderador.ToString();
            this.txtCodificacao.Text = selObject.Codificacao;

            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(selObject.TextoBase);
            perg.setupPergunta(p1, p1, false);
            this.lblAutoavaliacao.Text = "<p>" + perg.GetPerguntaText() + "</p>";
            Pessoa[] grupo = { p1, p3 };

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

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

            perg.setupPergunta(p3, p2, false);
            this.lblVasco.Text = "<p>" + perg.GetPerguntaText() + "</p>";
        }
    }
예제 #2
0
    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>";
    }