public void Insertar(int id_redactor) { try { if (this.copia != null) { return; } using (var r = new insertarTableAdapter( )) { using (var s = r.sp_bombero(1, null, this.nombre, this.apellido, this.dpi, null, (byte)this.estado, null, user == null ? null : (int?)user.ID, id_redactor)) { var ss = s.First( ); if (ss.out_status != 1) { throw new NoSePudoIngresarException(""); } this.copia = base.MemberwiseClone( ) as Bombero; this.id = ss.out_id; } } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } }
public void Editar(int id_redactor) { try { using (var r = new insertarTableAdapter( )) { using (var result = r.sp_bombero(2, this.id, IFC(this.nombre, copia.nombre), IFC(this.apellido, copia.apellido), IFC(this.dpi, copia.dpi), null, IF(this.estado, copia.estado), null, IFE(this.user == null ? null : (int?)this.user.ID, copia.user == null ? (int?)null : copia.user.ID), id_redactor)) { var row = result.First( ); if (row.out_status != 1200) { throw new NoSePuedeEliminarException("el tipo de incidente."); } //this.id = -1; this.copia = base.MemberwiseClone( ) as Bombero; } } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } }
public void Insertar(int id_redactor, string username, string contra, int id_acceso) { try { if (this.copia != null) { return; } using (var r = new insertarTableAdapter( )) { var id_user = -1; using (var s = r.sp_user(1, username, Usuario.CifrarValor(contra), id_acceso)) { var ss = s.First( ); if (ss.out_status != 1) { throw new NoSePudoIngresarException(""); } id_user = ss.out_id; } using (var s = r.sp_bombero(1, null, this.nombre, this.apellido, this.dpi, null, (byte)this.estado, null, id_user, id_redactor)) { var ss = s.First( ); if (ss.out_status != 1) { throw new NoSePudoIngresarException(""); } this.copia = base.MemberwiseClone( ) as Bombero; this.id = ss.out_id; } } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } }
public void Editar(int id_redactor, string username, string contra, int id_acceso) { try { if (HayUsuario) { throw new AlgoMasException( ); } using (var r = new insertarTableAdapter( )) { var id_user = -1; using (var s = r.sp_user(1, username, Usuario.CifrarValor(contra), id_acceso)) { var ss = s.First( ); if (ss.out_status != 1) { throw new NoSePudoIngresarException(""); } id_user = ss.out_id; } using (var result = r.sp_bombero(2, this.id, IFC(this.nombre, copia.nombre), IFC(this.apellido, copia.apellido), IFC(this.dpi, copia.dpi), null, IF(this.estado, copia.estado), null, id_user, id_redactor)) { var row = result.First( ); if (row.out_status != 1200) { throw new NoSePuedeEliminarException("el tipo de incidente."); } //this.id = -1; this.copia = base.MemberwiseClone( ) as Bombero; } } } catch (MySqlException ex) { var nex = Generador.GenerarDesdeMySqlException(ex); if (nex != null) { throw nex; } } }