protected void btnAccept_Click(object sender, ImageClickEventArgs e) { try { if (!DataOk()) { return; } if (newRecord) { TrabajoGroup = new GrupoTrabajo(); } UnloadData(TrabajoGroup); if (newRecord) { ctx.Add(TrabajoGroup); } 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); } }
public static void DeleteGrupoTrabajo(GrupoTrabajo gt, LainsaSci ctx) { if (gt.Usuarios != null) { foreach (Usuario u in gt.Usuarios) { u.GrupoTrabajo = null; } } ctx.Delete(gt); ctx.SaveChanges(); }
public bool add(GrupoTrabajoDTO grupoTrabajo) { using (var context = getContext()) { try { GrupoTrabajo nuevo = new GrupoTrabajo(); nuevo.Nombre = grupoTrabajo.Nombre; nuevo.Estado = grupoTrabajo.Estado; context.GrupoTrabajo.Add(nuevo); context.SaveChanges(); return(true); } catch (Exception e) { throw e; } } }
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, "grupotrabajogrid", 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; // Is it a new record or not? if (Request.QueryString["GrupoTrabajoId"] != null) { TrabajoGroup = CntLainsaSci.GetGrupoTrabajo(int.Parse(Request.QueryString["GrupoTrabajoId"]), ctx); LoadData(TrabajoGroup); 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)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]]; } switch (imgb.ID) { case "Select": break; case "Edit": break; case "Delete": try { GrupoTrabajo gpt = CntLainsaSci.GetGrupoTrabajo(id, ctx); CntLainsaSci.DeleteGrupoTrabajo(gpt, ctx); RefreshGrid(true); } catch (Exception ex) { ControlDeError(ex); } break; } } }
public static IList <Revision> GetRevisiones(Usuario u, GrupoTrabajo gt, LainsaSci ctx) { IList <Revision> rss = new List <Revision>(); foreach (Dispositivo dsp in GetDispositivos(ctx)) { foreach (Revision r in dsp.Revisiones) { if (r.Usuario != null) { if (r.Usuario.GrupoTrabajo != null) { if (r.Usuario.GrupoTrabajo.GrupoTrabajoId == u.GrupoTrabajo.GrupoTrabajoId) { rss.Add(r); } } } } } return(rss); }
protected void UnloadData(GrupoTrabajo gpTrabajo) { gpTrabajo.Nombre = txtNombre.Text; }
protected void LoadData(GrupoTrabajo gpTrabajo) { txtGrupoTrabajoId.Text = gpTrabajo.GrupoTrabajoId.ToString(); txtNombre.Text = gpTrabajo.Nombre; }