protected void Page_Init(object sender, EventArgs e) { // it gets an appropiate context (LainsaSciCTX -> web.config) ctx = new LainsaSci("LainsaSciCTX"); // verify if a Usuario is logged Usuario = CntWinWeb.IsSomeoneLogged(this, ctx); if (Usuario == null) { Response.Redirect("Default.aspx"); } else { Session["UsuarioId"] = Usuario.UsuarioId; } // // si llega aquí está autorizado permiso = CntLainsaSci.GetPermiso(Usuario.GrupoUsuario, "campogrid", ctx); if (permiso == null) { RadNotification1.Text = String.Format("<b>{0}</b><br/>{1}", (string)GetGlobalResourceObject("ResourceLainsaSci", "Warning"), (string)GetGlobalResourceObject("ResourceLainsaSci", "NoPermissionsAssigned")); RadNotification1.Show(); RadAjaxManager1.ResponseScripts.Add("closeWindow();"); } btnAccept.Visible = permiso.Modificar; if (Request.QueryString["Caller"] != null) { caller = Request.QueryString["Caller"]; caller = caller.Replace("'", ""); } if (Request.QueryString["PlantillaId"] != null) { plantilla = CntLainsaSci.GetPlantillaRevision(int.Parse(Request.QueryString["PlantillaId"]), ctx); CargaPlantilla(plantilla); } CargaTipos(new TipoCampo()); // Is it a new record or not? if (Request.QueryString["CampoId"] != null) { campo = CntLainsaSci.GetCampo(int.Parse(Request.QueryString["CampoId"]), ctx); LoadData(campo); newRecord = false; } else { CargarInformeDe(""); } // control de skin if (Session["Skin"] != null) { RadSkinManager1.Skin = Session["Skin"].ToString(); } }
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { // we only process commands with a datasource (our image buttons) if (e.CommandSource == null) { return; } string typeOfControl = e.CommandSource.GetType().ToString(); if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton")) { int id = 0; ImageButton imgb = (ImageButton)e.CommandSource; if (imgb.ID != "New" && imgb.ID != "Exit") { id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]]; } switch (imgb.ID) { case "Select": break; case "Edit": break; case "Delete": try { Campo campo = CntLainsaSci.GetCampo(id, ctx); foreach (DatosRevision dr in campo.DatosRevisions) { CntLainsaSci.CTXEliminar(dr, ctx); } CntLainsaSci.CTXEliminar(campo, ctx); CntLainsaSci.CTXGuardar(ctx); RefreshGrid(true); } catch (Exception ex) { ControlDeError(ex); } break; } } }