protected void btnSaveRefresh_Click(object sender, EventArgs e) { string Mode = Request.QueryString["Mode"].ToString(); OperationResult objOperationResult = new OperationResult(); if (Mode == "New") { // Create the entity systemparameterDto objEntity = new systemparameterDto(); // Populate the entity objEntity.i_GroupId = int.Parse(txtGroupId.Text.Trim()); objEntity.i_ParameterId = int.Parse(txtParameterId.Text.Trim()); objEntity.v_Value1 = txtDescription.Text.Trim().ToUpper(); if (txtUserInterfaceOrder.Text == "") { objEntity.i_Sort = null; } else { objEntity.i_Sort = int.Parse(txtUserInterfaceOrder.Text.Trim()); } objEntity.v_Value2 = txtDescription2.Text.Trim().ToUpper(); objEntity.v_Field = txtField.Text.Trim().ToUpper(); //objEntity.i_ParentGroupId = string.IsNullOrEmpty(ddlParentGroupId.SelectedValue) ? (Int32?)null : Int32.Parse(ddlParentGroupId.SelectedValue); objEntity.i_ParentParameterId = string.IsNullOrEmpty(ddlParentParameterId.SelectedValue) ? (Int32?)null : Int32.Parse(ddlParentParameterId.SelectedValue); // Obtener el usuario autenticado int intUserPersonId = ((ClientSession)Session["objClientSession"]).i_SystemUserId; if (_objProxy.GetSystemParameter(ref objOperationResult, objEntity.i_GroupId, objEntity.i_ParameterId) != null) { Alert.Show("¡ La clave primaria ya existe!", MessageBoxIcon.Warning); return; } else { // Save the data _objProxy.AddSystemParameter(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList()); } } else if (Mode == "Edit") { // Obtener el usuario autenticado int intUserPersonId = ((ClientSession)Session["objClientSession"]).i_SystemUserId; // Get the entity from the session systemparameterDto objEntity = (systemparameterDto)Session["objEntity"]; // Populate the entity objEntity.i_GroupId = int.Parse(txtGroupId.Text.Trim()); objEntity.i_ParameterId = int.Parse(txtParameterId.Text.Trim()); objEntity.v_Value1 = txtDescription.Text.Trim().ToUpper(); if (txtUserInterfaceOrder.Text == "") { objEntity.i_Sort = null; } else { objEntity.i_Sort = int.Parse(txtUserInterfaceOrder.Text.Trim()); } objEntity.v_Value2 = txtDescription2.Text.Trim().ToUpper(); objEntity.v_Field = txtField.Text.Trim().ToUpper(); //objEntity.i_ParentGroupId = string.IsNullOrEmpty(ddlParentGroupId.SelectedValue) ? (Int32?)null : Int32.Parse(ddlParentGroupId.SelectedValue); objEntity.i_ParentParameterId = string.IsNullOrEmpty(ddlParentParameterId.SelectedValue) ? (Int32?)null : Int32.Parse(ddlParentParameterId.SelectedValue); // Save the data _objProxy.UpdateSystemParameter(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList()); } else if (Mode == "NewChildren") { // Obtener el usuario autenticado int intUserPersonId = ((ClientSession)Session["objClientSession"]).i_SystemUserId; // Create the entity systemparameterDto objEntity = new systemparameterDto(); // Populate the entity objEntity.i_GroupId = int.Parse(txtGroupId.Text.Trim()); objEntity.i_ParameterId = int.Parse(txtParameterId.Text.Trim()); objEntity.v_Value1 = txtDescription.Text.Trim().ToUpper(); if (txtUserInterfaceOrder.Text == "") { objEntity.i_Sort = null; } else { objEntity.i_Sort = int.Parse(txtUserInterfaceOrder.Text.Trim()); } objEntity.v_Value2 = txtDescription2.Text.Trim().ToUpper(); objEntity.v_Field = txtField.Text.Trim().ToUpper(); //objEntity.i_ParentGroupId = string.IsNullOrEmpty(ddlParentGroupId.SelectedValue) ? (Int32?)null : Int32.Parse(ddlParentGroupId.SelectedValue); objEntity.i_ParentParameterId = string.IsNullOrEmpty(ddlParentParameterId.SelectedValue) ? (Int32?)null : Int32.Parse(ddlParentParameterId.SelectedValue); if (_objProxy.GetSystemParameter(ref objOperationResult, objEntity.i_GroupId, objEntity.i_ParameterId) != null) { Alert.Show("¡La clave primaria ya existe new children!", MessageBoxIcon.Warning); return; } else { // Save the data _objProxy.AddSystemParameter(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList()); } } //Analizar el resultado de la operación if (objOperationResult.Success == 1) // Operación sin error { // Cerrar página actual y hacer postback en el padre para actualizar PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else // Operación con error { Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage); // Se queda en el formulario. } }