protected void btnAccept_Click(object sender, ImageClickEventArgs e) { try { if (!DataOk()) { return; } if (newRecord) { TipoAnomalia = new TipoAnomalia(); } UnloadData(TipoAnomalia); if (newRecord) { ctx.Add(TipoAnomalia); } ctx.SaveChanges(); if (newRecord) { RadAjaxManager1.ResponseScripts.Add(String.Format("closeWindowRefreshGrid('{0}', 'new');", caller)); } else { RadAjaxManager1.ResponseScripts.Add(String.Format("closeWindowRefreshGrid('{0}', 'edit');", caller)); } } catch (Exception ex) { ControlDeError(ex); } }
protected void CargarTiposAnomalia(TipoAnomalia ta) { // borramos los elementos que ya pudiera tener el combo box rdcTipoAnomalia.Items.Clear(); // damos de alta todos los tipos que tenemos. foreach (TipoAnomalia ta2 in CntLainsaSci.GetTipoAnomalias(ctx)) { rdcTipoAnomalia.Items.Add(new RadComboBoxItem(ta2.Nombre, ta2.TipoAnomaliaId.ToString())); } rdcTipoAnomalia.Items.Add(new RadComboBoxItem(" ", "")); rdcTipoAnomalia.SelectedValue = ""; if (ta != null) { rdcTipoAnomalia.SelectedValue = ta.TipoAnomaliaId.ToString(); } }
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; } // permiso = CntLainsaSci.GetPermiso(usuario.GrupoUsuario, "TipoAnomaliagrid", 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; // load the combo // Is it a new record or not? if (Request.QueryString["TipoAnomaliaId"] != null) { TipoAnomalia = CntLainsaSci.GetTipoAnomalia(int.Parse(Request.QueryString["TipoAnomaliaId"]), ctx); LoadData(TipoAnomalia); newRecord = false; } 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 { TipoAnomalia p = CntLainsaSci.GetTipoAnomalia(id, ctx); CntLainsaSci.CTXEliminar(p, ctx); CntLainsaSci.CTXGuardar(ctx); RefreshGrid(true); } catch (Exception ex) { ControlDeError(ex); } break; } } }
protected void UnloadData(TipoAnomalia TipoAnomalia) { TipoAnomalia.Nombre = txtNombre.Text; }
protected void LoadData(TipoAnomalia TipoAnomalia) { txtNombre.Text = TipoAnomalia.Nombre; }