Exemple #1
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;
                }
            }
        }
Exemple #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;
                }
            }
        }
Exemple #3
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;
                }
            }
        }
Exemple #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;
                }
            }
        }
Exemple #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;
                }
            }
        }
Exemple #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;
                }
            }
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        public static List <Acceso> Incidentes( )
        {
            var s = null as List <Acceso>;

            try {
                using (var r = new accesoTableAdapter( )) {
                    s = r.GetData( ).Select(x => {
                        var n = new Acceso( )
                        {
                            nombre = x.nombre,
                            id     = x.id_acceso
                        };
                        //n.copia = n.MemberwiseClone ( ) as TipoIncidente;

                        return(n);
                    }).ToList( );
                }
            }
            catch (MySqlException ex) {
                var nex = Generador.GenerarDesdeMySqlException(ex);
                if (nex != null)
                {
                    throw nex;
                }
            }

            return(s);
        }
Exemple #9
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;
                }
            }
        }
Exemple #10
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;
                }
            }
        }