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; } // Is it a new record or not? if (Request.QueryString["EmailId"] != null) { email = CntLainsaSci.GetEmail(int.Parse(Request.QueryString["EmailId"].ToString()), ctx); LoadData(email); empresa = email.Empresa; instalacion = email.Instalacion; newRecord = false; } else { if (Request.QueryString["EmpresaId"] != null) { int empresaId = int.Parse(Request.QueryString["EmpresaId"]); empresa = CntLainsaSci.GetEmpresa(empresaId, ctx); lblPropietario.Text = "EMPRESA"; txtPropietario.Text = empresa.Nombre; } if (Request.QueryString["RevisionId"] != null) { int instalacionId = int.Parse(Request.QueryString["RevisionId"]); instalacion = CntLainsaSci.GetInstalacion(instalacionId, ctx); lblPropietario.Text = "INSTALACION"; txtPropietario.Text = instalacion.Nombre; } if (empresa == null && instalacion == null) { RadNotification1.Text = String.Format("<b>{0}</b><br/>{1}", (string)GetGlobalResourceObject("ResourceLainsaSci", "Warning"), (string)GetGlobalResourceObject("ResourceLainsaSci", "EmailWithoutOwner")); RadNotification1.Show(); } } if (Request.QueryString["Caller"] != null) { caller = Request.QueryString["Caller"]; } // 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.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]].ToString()); } switch (imgb.ID) { case "Select": break; case "Edit": break; case "Delete": try { Email em = CntLainsaSci.GetEmail(id, ctx); CntLainsaSci.CTXEliminar(em, ctx); CntLainsaSci.CTXGuardar(ctx); RefreshGrid(true); } catch (Exception ex) { ControlDeError(ex); } break; } } }