public void Insertar(int id_redactor) { try { if (this.copia != null) { return; } using (var r = new insertarTableAdapter( )) using (var s = r.sp_tipo_incidente(1, null, this.nombre, id_redactor)) { var ss = s.First( ); if (ss.out_status != 1) { throw new NoSePudoIngresarException(""); } this.copia = base.MemberwiseClone( ) as TipoIncidente; this.id = ss.out_id; } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } }
public static List <TipoIncidente> Incidentes( ) { var s = null as List <TipoIncidente>; try { using (var r = new tipo_incidenteTableAdapter( )) { s = r.GetData( ).Select(x => { var n = new TipoIncidente( ) { nombre = x.nombre, id = x.id_tipo_incidente, bloqueo = x.id_tipo_incidente > 0 && x.id_tipo_incidente < 40 }; n.copia = n.MemberwiseClone( ) as TipoIncidente; return(n); }).ToList( ); } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } return(s); }
public void Eliminar(int id_redactor) { try { if (this.bloqueo) { throw new BloqueoException( ); } using (var r = new insertarTableAdapter( )) { using (var result = r.sp_tipo_incidente(3, this.id, this.nombre, id_redactor)) { var row = result.First( ); if (row.out_status != 200) { throw new NoSePuedeEliminarException("el tipo de incidente."); } this.id = -1; this.copia = null; } } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } }
public void Eliminar(TipoIncidente eliminar) { if (eliminar == null) { return; } try { eliminar.Eliminar(0); if (this.incidentes != null) { this.incidentes.Remove(eliminar); } } catch (SinConexionException) { OnErrorMsgEliminar(eliminar); } catch (NoSePuedeEliminarException) { this.arg1 = this.arg1 ?? new ErrorMsgArgs( ); this.arg1.Motivo = "Hay una referencia al incidente."; OnErrorMsg(null); } catch (BloqueoException) { this.arg1 = this.arg1 ?? new ErrorMsgArgs( ); this.arg1.Motivo = "Esta prestablecido."; OnErrorMsg(null); } catch (Exception) { throw; } }
public void Agregar(TipoIncidente nuevo) { if (nuevo == null) { return; } nuevo.Insertar(0); if (this.incidentes != null) { this.incidentes.Add(nuevo); } }
public void ActualizarLista( ) { try { var incidentes = TipoIncidente.Incidentes( ); if (incidentes == null) { throw new Excepciones.SinConexionException( ); } this.incidentes = new ObservableCollection <TipoIncidente> (incidentes); base.OnPropertyChanged("Incidentes"); } catch (Excepciones.SinConexionException) { OnErrorMsgSinConexion( ); } }
private void OnErrorMsgEliminar(TipoIncidente item) { if (this.errorMsg == null) { return; } this.arg1 = this.arg1 ?? new ErrorMsgArgs( ); this.arg1.Reintentar = true; this.errorMsg.ErrorEnEliminar(this.arg1); if (this.arg1.Reintentar) { var t = new Timer(x => this.Eliminar(item)); t.Change(TimeSpan.FromSeconds(1), Timeout.InfiniteTimeSpan); } }
public TipoIncidente( ) { this.id = -1; this.nombre = string.Empty; this.copia = null; }