Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
        public void Editar(int id_redactor)
        {
            try {
                using (var r = new insertarTableAdapter( )) {
                    using (var result = r.sp_unidad_movil(2, this.id, IF(this.numero, copia.numero), IFC(this.placa, copia.placa), IF(this.estado, copia.estado), 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 UnidadMovil;
                    }
                }
            }
            catch (MySqlException ex) {
                var nex = Generador.GenerarDesdeMySqlException(ex);

                if (nex != null)
                {
                    throw nex;
                }
            }
        }
Ejemplo n.º 4
0
        public void Insertar(int id_redactor)
        {
            try {
                if (this.copia != null)
                {
                    return;
                }

                using (var r = new insertarTableAdapter( ))
                    using (var s = r.sp_unidad_movil(1, null, this.numero, this.placa, this.estado, id_redactor)) {
                        var ss = s.First( );

                        if (ss.out_status != 1)
                        {
                            throw new NoSePudoIngresarException("");
                        }

                        this.copia = base.MemberwiseClone( ) as UnidadMovil;
                        this.id    = ss.out_id;
                    }
            }
            catch (MySqlException ex) {
                var nex = Generador.GenerarDesdeMySqlException(ex);

                if (nex != null)
                {
                    throw nex;
                }
            }
        }
Ejemplo n.º 5
0
        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;
                }
            }
        }
Ejemplo n.º 6
0
        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;
                }
            }
        }
Ejemplo n.º 7
0
        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;
                }
            }
        }
Ejemplo n.º 8
0
        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;
                }
            }
        }