Пример #1
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            var             locationId         = "";
            string          Mode               = Request.QueryString["Mode"].ToString();
            OperationResult objOperationResult = new OperationResult();

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

                // Populate the entity
                objEntity.v_OrganizationId = Session["v_OrganizationId"].ToString();
                objEntity.v_Name           = txtSede.Text;

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

                //Rutina para Asignar la Empresa creada automaticamente al nodo actual
                NodeOrganizationLoactionWarehouseList objNodeOrganizationLoactionWarehouseList = new NodeOrganizationLoactionWarehouseList();
                List <nodeorganizationlocationwarehouseprofileDto> objnodeorganizationlocationwarehouseprofileDto = new List <nodeorganizationlocationwarehouseprofileDto>();

                //Llenar Entidad Empresa/sede
                objNodeOrganizationLoactionWarehouseList.i_NodeId         = 9;
                objNodeOrganizationLoactionWarehouseList.v_OrganizationId = Session["v_OrganizationId"].ToString();
                objNodeOrganizationLoactionWarehouseList.v_LocationId     = locationId;

                //Llenar Entidad Almacén
                var objInsertWarehouseList = InsertWarehouse(locationId);


                oOrganizationBL.AddNodeOrganizationLoactionWarehouse(ref objOperationResult, objNodeOrganizationLoactionWarehouseList, objInsertWarehouseList, ((ClientSession)Session["objClientSession"]).GetAsList());
            }
            else if (Mode == "Edit")
            {
                locationDto objEntity = new locationDto();

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