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

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

                // Populate the entity
                objEntity.v_LocationId = ddlLocation.SelectedValue.ToString();
                objEntity.v_Name       = txtSede.Text;

                // Save the data
                oOrganizationBL.AddGroupOccupation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());

                if (txtSede2.Text.Trim() != "")
                {
                    objEntity = new groupoccupationDto();

                    // Populate the entity
                    objEntity.v_LocationId = ddlLocation.SelectedValue.ToString();
                    objEntity.v_Name       = txtSede2.Text;

                    // Save the data
                    oOrganizationBL.AddGroupOccupation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
                }

                if (txtSede3.Text.Trim() != "")
                {
                    objEntity = new groupoccupationDto();

                    // Populate the entity
                    objEntity.v_LocationId = ddlLocation.SelectedValue.ToString();
                    objEntity.v_Name       = txtSede3.Text;

                    // Save the data
                    oOrganizationBL.AddGroupOccupation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
                }

                if (txtSede4.Text.Trim() != "")
                {
                    objEntity = new groupoccupationDto();

                    // Populate the entity
                    objEntity.v_LocationId = ddlLocation.SelectedValue.ToString();
                    objEntity.v_Name       = txtSede4.Text;

                    // Save the data
                    oOrganizationBL.AddGroupOccupation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
                }

                if (txtSede5.Text.Trim() != "")
                {
                    objEntity = new groupoccupationDto();

                    // Populate the entity
                    objEntity.v_LocationId = ddlLocation.SelectedValue.ToString();
                    objEntity.v_Name       = txtSede5.Text;

                    // Save the data
                    oOrganizationBL.AddGroupOccupation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList());
                }
            }
            else if (Mode == "Edit")
            {
                groupoccupationDto objEntity = new groupoccupationDto();

                // Populate the entity
                objEntity.v_GroupOccupationId = Session["v_GroupOccupationId"].ToString();
                objEntity.v_LocationId        = Session["v_LocationId"].ToString();
                objEntity.v_Name = txtSede.Text;
                oOrganizationBL.UpdateGroupOccupation(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.
            }
        }