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 { string file; CargaTerminales p = CntLainsaSci.GetCargaTerminal(id, ctx); file = p.Archivo; CntLainsaSci.CTXEliminar(p, ctx); CntLainsaSci.CTXGuardar(ctx); RefreshGrid(true); string path = String.Format("{0}BDII\\{1}", this.MapPath("/"), file); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ControlDeError(ex); } break; } } }
public void GuardarTerminal() { try { terminal = CntLainsaSci.GetCargaTerminal(archivo, ctx); if (terminal == null) { terminal = new CargaTerminales(); terminal.Empresa = empresa; terminal.Archivo = archivo; terminal.Fecha = DateTime.Now; ctx.Add(terminal); } terminal.Fecha = DateTime.Now; ctx.SaveChanges(); } catch (Exception ex) { ControlDeError(ex); } }