Ejemplo n.º 1
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            string          Mode = Request.QueryString["Mode"].ToString();
            OperationResult objOperationResult = new OperationResult();

            if (Mode == "New")
            {
                // Create the entity
                attentioninareaDto objEntity = new attentioninareaDto();

                // Populate the entity
                objEntity.v_Name         = txtName.Text.Trim().ToUpper();
                objEntity.v_OfficeNumber = txtOfficeNumber.Text.Trim().ToUpper();

                // Save the data
                AttentionInAreaId = _objNodeBL.AddAttentionInAreaByNode(ref objOperationResult, objEntity, InsertAttentionAreaComponent(), ((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
                attentioninareaDto objEntity = (attentioninareaDto)Session["objEntity"];

                // Populate the entity
                objEntity.v_Name         = txtName.Text.Trim().ToUpper();
                objEntity.v_OfficeNumber = txtOfficeNumber.Text.Trim().ToUpper();

                var objAddAttentionAreaComponentList    = UpdateAttentionAreaComponent();
                var objDeleteAttentionAreaComponentList = DeleteAttentionAreaComponent();

                // Save the data
                _objNodeBL.UpdateAttentionInAreaByNode(ref objOperationResult, objEntity, objAddAttentionAreaComponentList, objDeleteAttentionAreaComponentList, ((attentioninareaDto)Session["objEntity"]).v_AttentionInAreaId, ((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.
            }
        }