Ejemplo n.º 1
0
        private void LoadData()
        {
            OperationResult objOperationResult = new OperationResult();
            //Llenado de combos
            Utils UtilComboBox = new Utils();

            string Mode = Request.QueryString["Mode"].ToString();
            int    GroupId = -1, ParameterId = -1;

            if (Request.QueryString["i_GroupId"] != null)
            {
                GroupId = int.Parse(Request.QueryString["i_GroupId"].ToString());
            }
            if (Request.QueryString["i_ParameterId"] != null)
            {
                ParameterId = int.Parse(Request.QueryString["i_ParameterId"].ToString());
            }

            //Llenar combo ItemParameter Tree
            ddlParentParameterId.DataTextField              = "Description";
            ddlParentParameterId.DataValueField             = "Id";
            ddlParentParameterId.DataSimulateTreeLevelField = "Level";
            ddlParentParameterId.DataEnableSelectField      = "EnabledSelect";
            List <DataForTreeViewSP> t = _objProxy.GetSystemParameterForComboTreeView(ref objOperationResult, GroupId).ToList();

            ddlParentParameterId.DataSource = t;
            ddlParentParameterId.DataBind();
            this.ddlParentParameterId.Items.Insert(0, new FineUI.ListItem("-- Seleccione --", "-1"));

            if (Mode == "New")
            {
                txtGroupId.Enabled           = false;
                txtGroupId.Text              = "0";
                ddlParentParameterId.Enabled = false;

                // Autogenerar ID para el nuevo grupo
                var groupId = _objProxy.GetSystemParameterMaxGroupId();
                txtGroupId.Text = groupId.ToString();
            }
            else if (Mode == "Edit")
            {
                // Bloquear algunos campos
                txtGroupId.Enabled           = false;
                txtParameterId.Enabled       = false;
                ddlParentParameterId.Enabled = true;

                // Get the Entity Data
                systemparameterDto objEntity = _objProxy.GetSystemParameter(ref objOperationResult, GroupId, ParameterId);

                // Save the entity on the session
                Session["objEntity"] = objEntity;

                // Show the data on the form
                txtGroupId.Text     = objEntity.i_GroupId.ToString();
                txtParameterId.Text = objEntity.i_ParameterId.ToString();
                txtDescription.Text = objEntity.v_Value1;
                if (objEntity.i_Sort.HasValue)
                {
                    txtUserInterfaceOrder.Text = objEntity.i_Sort.Value.ToString();
                }
                txtDescription2.Text = objEntity.v_Value2;
                txtField.Text        = objEntity.v_Field;

                //Llenado de combos
                //Utils.LoadDropDownList(ddlParentGroupId, "Value1", "Id", _objProxy.GetSystemParameterForCombo(ref objOperationResult, 0), DropDownListAction.Select);
                //Utils.LoadDropDownList(ddlParentParameterId, "Value1", "Id", _objProxy.GetSystemParameterForCombo(ref objOperationResult, (int)objEntity.i_ParentGroupId), DropDownListAction.Select);

                //ddlParentGroupId.SelectedValue = objEntity.i_ParentGroupId.ToString();
                ddlParentParameterId.SelectedValue = objEntity.i_ParentParameterId.ToString();
                txtDescription2.Focus(true);

                if (GroupId == 0)
                {
                    ddlParentParameterId.Enabled = false;
                }
            }
            if (Mode == "NewChildren")
            {
                txtGroupId.Text    = GroupId.ToString();
                txtGroupId.Enabled = false;

                // Autogenerar ID para el nuevo parametro
                var paramId = _objProxy.GetSystemParameterMaxParameterId(GroupId);
                txtParameterId.Text = paramId.ToString();
                //txtParameterId.Enabled = false;

                txtUserInterfaceOrder.Focus();
            }
        }