protected void dgdPoliticas_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            hfIndex.Value = e.Item.ItemIndex.ToString();
            dgdPoliticas.EditItemIndex = e.Item.ItemIndex;

            ArrayList arrPoliticas = WFPolitica.ObtenerPoliticasPorWorkflowId(WorkflowId);

            dgdPoliticas.DataSource = arrPoliticas;
            dgdPoliticas.DataBind();

            DropDownList ddlTipoDeDato = (DropDownList)dgdPoliticas.Items[e.Item.ItemIndex].FindControl("ddlTipoDeDatoItem");

            ddlTipoDeDato.DataSource     = WFTipoDeDato.ObtenerTiposDeDato();
            ddlTipoDeDato.DataValueField = "intCodTipoDeDato";
            ddlTipoDeDato.DataTextField  = "strNbrTipoDeDato";
            ddlTipoDeDato.DataBind();

            ddlTipoDeDato.Items.FindByValue(((WFPolitica)arrPoliticas[e.Item.ItemIndex]).objTipoDeDato.intCodTipoDeDato.ToString()).Selected = true;

            DropDownList ddlCondicion = (DropDownList)dgdPoliticas.Items[e.Item.ItemIndex].FindControl("ddlCondicionItem");

            ddlCondicion.DataSource     = WFCondicion.ObtenerCondiciones();
            ddlCondicion.DataValueField = "intCodCondicion";
            ddlCondicion.DataTextField  = "strNbrCondicion";
            ddlCondicion.DataBind();

            ddlCondicion.Items.FindByValue(((WFPolitica)arrPoliticas[e.Item.ItemIndex]).objCondicion.intCodCondicion.ToString()).Selected = true;

            //ImageButton ib = (ImageButton)FindMyControl(this, "ibtnActualizar");
            //ib.Attributes.Add("onclick", "javascritp:jsUpdate(" + e.Item.ItemIndex + ");");
//			DeshabilitarValidadores();
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WorkflowId = Convert.ToInt32(Context.Items["intWorkflowId"]);
            //WorkflowId = Convert.ToInt32(Request.Params["intWorkflowId"]);
            lblTituloArbol.Text = "'" + Convert.ToString(Context.Items["strNombre"]) + "'";
            blnConsultar = Convert.ToBoolean(Context.Items["blnConsultar"]);
            //tvWorkflow.Visible = true;
            //tvWorkflow.ExpandLevel = NIVELES_EXPANDIDOS;

            wfTreeView.Visible = true;
            wfTreeView.ExpandAll();

            if (WorkflowId != -1)
            {
                //tvWorkflow.TreeNodeSrc = WFPolitica.ObtenerRepresentacionXmlConRoles(WorkflowId);
                //tvWorkflow.DataBind();

                wfTreeView.DataSource = WFPolitica.ObtenerRepresentacionXmlDataSourceConRoles(WorkflowId);

                TreeNodeBinding Binding = new TreeNodeBinding();
                Binding.TextField = "FullName";
                Binding.ValueField = "ID";
                wfTreeView.DataBindings.Add(Binding);

                wfTreeView.DataBind();

                if (blnConsultar)
                {
                    lblTitulo.Text = "Workflow > Consultar rutas de aprobación";
                    btnSalir.Text = "Regresar";
                }
            }
        }
        public void Initialize()
        {
            BindCombos();
            BindPoliticas();

            //Microsoft.Web.UI.WebControls.TreeView tvw = (Microsoft.Web.UI.WebControls.TreeView)ES.Web.Global.FindMyControl(Page, "tvWorkflow");
            //tvw.Visible = true;
            //tvw.ExpandLevel = NIVELES_EXPANDIDOS;
            //NodeIndex = tvw.SelectedNodeIndex;

            //if(WorkflowId != -1)
            //{
            //    tvw.TreeNodeSrc = WFPolitica.ObtenerRepresentacionXml(WorkflowId);
            //    tvw.DataBind();
            //}

            System.Web.UI.WebControls.TreeView wft = (System.Web.UI.WebControls.TreeView)Web.Global.FindMyControl(Page, "wfTreeView");
            wft.Visible = true;
            wft.ExpandAll();
            //NodeIndex = wft.SelectedValue;

            if (WorkflowId != -1)
            {
                wft.DataSource = WFPolitica.ObtenerRepresentacionXmlDataSource(WorkflowId);

                // we want the full name displayed in the tree so
                // do custom databindings
                TreeNodeBinding Binding = new TreeNodeBinding();
                Binding.TextField  = "FullName";
                Binding.ValueField = "ID";
                wft.DataBindings.Add(Binding);

                wft.DataBind();

                //string xml = WFPolitica.ObtenerRepresentacionXml(WorkflowId);
                //XmlDocument XDoc = new XmlDocument();
                //XmlDeclaration XDec = XDoc.CreateXmlDeclaration("1.0", null, null);
                //XDoc.AppendChild(XDec);
                //XDoc.LoadXml(xml);
                ////string str = XDoc.OuterXml;

                //// we cannot bind the TreeView directly to an XmlDocument
                //// so we must create an XmlDataSource and assign the XML text
                //XmlDataSource XDdataSource = new XmlDataSource();
                //XDdataSource.ID = DateTime.Now.Ticks.ToString();  // unique ID is required
                //XDdataSource.Data = XDoc.OuterXml;

                //// we want the full name displayed in the tree so
                //// do custom databindings
                //TreeNodeBinding Binding = new TreeNodeBinding();
                //Binding.TextField = "Text";
                //Binding.ValueField = "NodeData";
                //wft.DataBindings.Add(Binding);

                //// Finally! Hook that bad boy up!
                //wft.DataSource = XDdataSource;
                //wft.DataBind();
            }
        }
        protected void dgdPoliticas_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            ArrayList arrPoliticas   = WFPolitica.ObtenerPoliticasPorWorkflowId(WorkflowId);
            int       intCodPadre    = ((WFPolitica)arrPoliticas[e.Item.ItemIndex]).intCodPadre;
            int       intCodWorkflow = ((WFPolitica)arrPoliticas[e.Item.ItemIndex]).WorkflowId;

            WFPolitica.BorrarPoliticasEnCadena(intCodPadre, intCodWorkflow);

            Initialize();
        }
        protected void hfCommand_ValueChanged(object sender, EventArgs e)
        {
            if (hfCommand.Value == "Update")
            {
                int index = Convert.ToInt32(hfIndex.Value);

                int hftipo = Convert.ToInt32(hfTipoDeDato.Value);
                int hfcond = Convert.ToInt32(hfCondicion.Value);

                if (hftipo != 0 && hfcond != 0 && hfValor.Value != String.Empty)
                {
                    ArrayList politicas   = (ArrayList)dgdPoliticas.DataSource;
                    ArrayList tiposdedato = (ArrayList)ddlTipo.DataSource;
                    ArrayList condiciones = (ArrayList)ddlCondicion.DataSource;

                    WFPolitica selected = (WFPolitica)politicas[index];
                    selected.objTipoDeDato = (WFTipoDeDato)tiposdedato[hftipo];
                    selected.objCondicion  = (WFCondicion)condiciones[hfcond];
                    selected.strValor      = hfValor.Value;
                    //selected.Update();
                }
                //selected.

                //ddlCondicion.DataSource = WFCondicion.ObtenerCondiciones();


                //int condId = ((WFCondicion)cond[index]).intCodCondicion;

                //System.Web.UI.WebControls.TreeView tvw = (System.Web.UI.WebControls.TreeView)Componentes.Web.Global.FindMyControl(Page, "wfTreeView");
                //System.Web.UI.WebControls.TreeNode tn = Global.GetNodeFromPath(tvw.Nodes, NodeIndex);
                //DropDownList ddlTipoDeDato = (DropDownList)Global.FindMyControl(Page, "ddlTipoDeDatoItem");
                //string tipoDeDatoSelected = ddlTipoDeDato.SelectedValue;
            }

            if (hfCommand.Value == "Cancel")
            {
                int index = Convert.ToInt32(hfIndex.Value);

                //dgdPoliticas.EditItemIndex = -1;
                //dgdPoliticas.DataSource = WFPolitica.ObtenerPoliticasPorWorkflowId(WorkflowId);
                //dgdPoliticas.DataBind();
            }

            hfCommand.Value = "";
        }
        public void Initialize()
        {
            lstNiveles.Items.Clear();
            lstEscogencia.Items.Clear();

            System.Web.UI.WebControls.TreeView wft = (System.Web.UI.WebControls.TreeView)Web.Global.FindMyControl(Page, "wfTreeView");
            wft.Visible = true;
            wft.ExpandAll();
            //NodeIndex = wft.SelectedValue;

            if (WorkflowId != -1 && FirstTime)
            {
                FirstTime      = false;
                wft.DataSource = WFPolitica.ObtenerRepresentacionXmlDataSourceConRutas(WorkflowId);

                // we want the full name displayed in the tree so
                // do custom databindings
                TreeNodeBinding Binding = new TreeNodeBinding();
                Binding.TextField  = "FullName";
                Binding.ValueField = "ID";
                wft.DataBindings.Add(Binding);

                wft.DataBind();
            }

            System.Web.UI.WebControls.TreeNode tn = Global.GetNodeFromPath(wft.Nodes, NodeIndex);
            if (tn == null || tn.ChildNodes.Count > 1)
            {
                return;                                        //MOSTRAR ALGUN MENSAJE DE ALARMA: no es una hoja donde se pueda conseguir una ruta
            }
            int ID = 0;

            if (tn.Value[0] == 'R')
            {
                ID = Convert.ToInt32(tn.Value.Substring(2));

                //lstNiveles.DataSource = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
                lstNiveles.DataSource     = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(0);
                lstNiveles.DataTextField  = "strNbrRoles";
                lstNiveles.DataValueField = "intCodRoles";
                lstNiveles.DataBind();

                lstEscogencia.DataSource     = WFGrupoDeRoles.ObtenerGruposDeRoles(ID, tn.Text);
                lstEscogencia.DataTextField  = "strNbrRoles";
                lstEscogencia.DataValueField = "intCodRoles";
                lstEscogencia.DataBind();
            }
            else
            {
                lstNiveles.DataSource     = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
                lstNiveles.DataTextField  = "strNbrRoles";
                lstNiveles.DataValueField = "intCodRoles";
                lstNiveles.DataBind();
            }

            /*
             * Microsoft.Web.UI.WebControls.TreeView tvw = (Microsoft.Web.UI.WebControls.TreeView)Page.FindControl("tvWorkflow");
             *          if(WorkflowId != -1 && FirstTime)
             *          {
             *                  FirstTime = false;
             *                  tvw.TreeNodeSrc = WFPolitica.ObtenerRepresentacionXmlConRutas(WorkflowId);
             *                  tvw.DataBind();
             *          }
             *
             *          tvw.Visible = true;
             *          tvw.AutoPostBack = true;
             *          tvw.ExpandLevel = NIVELES_EXPANDIDOS;
             *
             *          NodeIndex = tvw.SelectedNodeIndex;
             *          Microsoft.Web.UI.WebControls.TreeNode tn = tvw.GetNodeFromIndex(NodeIndex);
             *          int ID = 0;
             *          if(tn != null)
             *          {
             *                  if(tn.NodeData[0] != 'N')
             *                  {
             *                          ID = Convert.ToInt32(tn.NodeData);
             *
             *                          lstNiveles.DataSource = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
             *                          lstNiveles.DataTextField = "strNbrRoles";
             *                          lstNiveles.DataValueField = "intCodRoles";
             *                          lstNiveles.DataBind();
             *
             *                          lstEscogencia.DataSource = WFGrupoDeRoles.ObtenerGruposDeRoles(ID,tn.Text);
             *                          lstEscogencia.DataTextField = "strNbrRoles";
             *                          lstEscogencia.DataValueField = "intCodRoles";
             *                          lstEscogencia.DataBind();
             *                  }
             *                  else
             *                  {
             *                          lstNiveles.DataSource = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
             *                          lstNiveles.DataTextField = "strNbrRoles";
             *                          lstNiveles.DataValueField = "intCodRoles";
             *                          lstNiveles.DataBind();
             *                  }
             *          }*/
        }
        protected void ibtnAgregar_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            int    Condicion = Int32.Parse(ddlCondicion.SelectedItem.Value);
            int    Tipo      = Int32.Parse(ddlTipo.SelectedItem.Value);
            string Valor     = txtPolitica.Text;
            Label  lblError  = (Label)Global.FindMyControl(Page, "lblError");

            if (Condicion == 0 || Tipo == 0 || Valor == "")
            {
                lblError.Visible = true;
                lblError.Text    = ESMensajes.ObtenerMensaje(551);
                return;
            }
            else
            {
                lblError.Visible = false;
            }

            WFCondicion  objCondicion = WFCondicion.ObtenerCondicionPorID(Condicion);
            WFTipoDeDato objTipo      = WFTipoDeDato.ObtenerTiposDeDatoPorID(Tipo);

            //Microsoft.Web.UI.WebControls.TreeView tvw = (Microsoft.Web.UI.WebControls.TreeView)Page.FindControl("tvWorkflow");
            System.Web.UI.WebControls.TreeView tvw = (System.Web.UI.WebControls.TreeView)Web.Global.FindMyControl(Page, "wfTreeView");

            System.Web.UI.WebControls.TreeNode tn = Global.GetNodeFromPath(tvw.Nodes, NodeIndex);
            if (tn == null || tn.ChildNodes.Count > 0)
            {
                return;                                        //MOSTRAR ALGUN MENSAJE DE ALARMA: no se puede indexar más de una política dentro de otra
            }
            int        ID          = Convert.ToInt32(tn.Value);
            WFPolitica newPolitica = new WFPolitica(WorkflowId, 0, ID, objCondicion, Valor, objTipo);

            if (newPolitica.Save())
            {
                ddlCondicion.SelectedIndex = 0;
                ddlTipo.SelectedIndex      = 0;
                txtPolitica.Text           = "";
                BindPoliticas();

                tvw.DataSource = WFPolitica.ObtenerRepresentacionXmlDataSource(WorkflowId);
                tvw.DataBind();
                HiddenField nodeIndex = (HiddenField)Global.FindMyControl(Page, "NodeIndex");
                nodeIndex.Value  = "0";
                lblError.Visible = false;
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = ESMensajes.ObtenerMensaje(302);
            }

            //Microsoft.Web.UI.WebControls.TreeNode tn = tvw.GetNodeFromIndex(NodeIndex);
            //int ID = 0;
            //if(tn.NodeData != "") ID = Convert.ToInt32(tn.NodeData);

            //WFPolitica newPolitica = new WFPolitica(WorkflowId, 0, ID, objCondicion, Valor, objTipo);
            //if (newPolitica.Save())
            //{
            //    ddlCondicion.SelectedIndex = 0;
            //    ddlTipo.SelectedIndex = 0;
            //    txtPolitica.Text = "";
            //    BindPoliticas();

            //    tvw.TreeNodeSrc = WFPolitica.ObtenerRepresentacionXml(WorkflowId);
            //    tvw.DataBind();
            //    lblError.Visible = false;
            //}
            //else
            //{
            //    lblError.Visible = true;
            //    lblError.Text = ESMensajes.ObtenerMensaje(302);
            //}
        }
 public void BindPoliticas()
 {
     dgdPoliticas.DataSource = WFPolitica.ObtenerPoliticasPorWorkflowId(WorkflowId);
     dgdPoliticas.DataBind();
 }