Пример #1
0
        public bool ConsultarCliente()
        {
            SQL = "SELECT dbo.TBL_CLIENTE.ID_CLIENTE, dbo.TBL_CLIENTE.NOMBRE_COMPLETO, dbo.TBL_RESERVA.ESTADO_RESERVA, " +
                  " dbo.TBL_CLIENTE.DOCUMENTO " +
                  " FROM dbo.TBL_CLIENTE INNER JOIN " +
                  " dbo.TBL_RESERVA ON dbo.TBL_CLIENTE.ID_CLIENTE = dbo.TBL_RESERVA.ID_CLIENTE" +
                  " WHERE(DOCUMENTO = @documento) AND (dbo.TBL_RESERVA.ESTADO_RESERVA = 'activa')";

            /* SQL = "SELECT   strNombre_CLIE, strPrimerApellido_CLIE, " +
             *              "strSegundoApellido_CLIE, strDireccion_CLIE " +
             *     "FROM     tblCliente " +
             *     "WHERE    strDocumento_CLIE = @prDocumento";*/

            clsConexion oConexion = new clsConexion();

            oConexion.SQL = SQL;
            oConexion.AgregarParametro("@documento", Documento);
            //Se invoca el método consultar
            if (oConexion.Consultar())
            {
                //Se verifica si hay datos
                if (oConexion.Reader.HasRows)
                {
                    //Tiene filas, se debe leer la información
                    oConexion.Reader.Read();
                    //Se captura la información
                    idCliente       = oConexion.Reader.GetInt32(0);
                    Nombre_Completo = oConexion.Reader.GetString(1);
                    EstadoReserva   = oConexion.Reader.GetString(2);
                    Documento       = oConexion.Reader.GetInt32(3);



                    //Libera memoria
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    //No tiene filas, se levanta un error
                    Error = "El cliente con el documento " + Documento +
                            " no está en la base de datos. \n O no tiene un reserva activa \n Verifique la información ingresada";
                    //Cerrar la conexión
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                Error = oConexion.Error;
                //Se debe cerrar la conexión
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }
Пример #2
0
        public bool ConsultarVehiculo()
        {
            SQL = "SELECT PLACA FROM TBL_VEHICULO WHERE PLACA = @prPlaca";

            /* SQL = "SELECT   strNombre_CLIE, strPrimerApellido_CLIE, " +
             *              "strSegundoApellido_CLIE, strDireccion_CLIE " +
             *     "FROM     tblCliente " +
             *     "WHERE    strDocumento_CLIE = @prDocumento";*/

            clsConexion oConexion = new clsConexion();

            oConexion.SQL = SQL;
            oConexion.AgregarParametro("@prPlaca", Placa);
            //Se invoca el método consultar
            if (oConexion.Consultar())
            {
                //Se verifica si hay datos
                if (oConexion.Reader.HasRows)
                {
                    //Tiene filas, se debe leer la información
                    oConexion.Reader.Read();
                    //Se captura la información
                    Placa = oConexion.Reader.GetString(0);

                    //Libera memoria
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    //No tiene filas, se levanta un error
                    Error = "La Placa  " + Placa +
                            " no está en la base de datos. \n O no tiene un reserva activa \n Verifique la información ingresada";
                    //Cerrar la conexión
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                Error = oConexion.Error;
                //Se debe cerrar la conexión
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }
Пример #3
0
        public bool Consultar()
        {
            SQL = "Propietario_Consultar";

            clsConexion oConexion = new clsConexion();

            oConexion.SQL             = SQL;
            oConexion.StoredProcedure = true;
            oConexion.AgregarParametro("@prCedula", System.Data.SqlDbType.Int, 20, Cedula);
            //Se invoca el método consultar
            if (oConexion.Consultar())
            {
                //Se verifica si hay datos
                if (oConexion.Reader.HasRows)
                {
                    //Tiene filas, se debe leer la información
                    oConexion.Reader.Read();
                    //Se captura la información
                    Nombre   = oConexion.Reader.GetString(0);
                    Edad     = oConexion.Reader.GetInt32(1);
                    Telefono = oConexion.Reader.GetString(2);

                    //Libera memoria
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    //No tiene filas, se levanta un error
                    Error = "El cliente con el Cedula " + Cedula +
                            " no está en la base de datos. \nVerifique la información " +
                            "o ingréselo al sistema";
                    //Cerrar la conexión
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                Error = oConexion.Error;
                //Se debe cerrar la conexión
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }
Пример #4
0
        private bool GrabarEncabezado()
        {
            SQL = "Factura_GrabarEncabezado";

            clsConexion oConexion = new clsConexion();

            oConexion.SQL             = SQL;
            oConexion.StoredProcedure = true;
            oConexion.AgregarParametro("@prCedulaPropietario", System.Data.SqlDbType.BigInt, 20, Cedula);
            oConexion.AgregarParametro("@prVendedor", System.Data.SqlDbType.Int, 4, Vendedor);
            //Ejecuta consultar
            if (oConexion.Consultar())
            {
                //Guarda los datos en un objeto Reader, permite leer los datos hacia adelante (Cada fila)
                //En cada fila, el READER maneja los datos como un vector.
                //Lo primero que se revisa es si hay datos.
                if (oConexion.Reader.HasRows)
                {
                    //Se debe leer el Reader
                    oConexion.Reader.Read();
                    NumeroFactura = oConexion.Reader.GetInt32(0);
                    //Cerrar conexion, liberar y retornar
                    Error = " el número de factura: " + NumeroFactura;
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    Error = "No pudo generar el número de factura";
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                Error = oConexion.Error;
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }
Пример #5
0
        public bool ConsultarPrecio()
        {
            SQL = "Repuesto_ConsultarValorUnitario";

            clsConexion oConexion = new clsConexion();

            oConexion.SQL             = SQL;
            oConexion.StoredProcedure = true;
            oConexion.AgregarParametro("@prCodigo", System.Data.SqlDbType.Int, 4, codigo);
            //Ejecuta consultar
            if (oConexion.Consultar())
            {
                //Guarda los datos en un objeto Reader, permite leer los datos hacia adelante (Cada fila)
                //En cada fila, el READER maneja los datos como un vector.
                //Lo primero que se revisa es si hay datos.
                if (oConexion.Reader.HasRows)
                {
                    //Se debe leer el Reader
                    oConexion.Reader.Read();
                    //Se leen los datos por posición y tipo de dato
                    valor = oConexion.Reader.GetDouble(0);
                    //Cerrar conexion, liberar y retornar
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    error = "No existen Repuesto con el código: " + codigo;
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                error = oConexion.Error;
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }
Пример #6
0
        private bool CalcularTotal()
        {
            SQL = "Factura_CalcularTotal";

            clsConexion oConexion = new clsConexion();

            oConexion.SQL             = SQL;
            oConexion.StoredProcedure = true;
            oConexion.AgregarParametro("@prFactura", System.Data.SqlDbType.Int, 20, NumeroFactura);
            //Ejecuta consultar
            if (oConexion.Consultar())
            {
                //Guarda los datos en un objeto Reader, permite leer los datos hacia adelante (Cada fila)
                //En cada fila, el READER maneja los datos como un vector.
                //Lo primero que se revisa es si hay datos.
                if (oConexion.Reader.HasRows)
                {
                    //Se debe leer el Reader
                    oConexion.Reader.Read();
                    Total = oConexion.Reader.GetInt32(0);
                    //Cerrar conexion, liberar y retornar
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    Error = "No pudo consultar el total de la factura: " + NumeroFactura;
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                Error = oConexion.Error;
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }
Пример #7
0
        public bool LlenarGridWeb()
        {
            if (grdGenerico == null)
            {
                strError = "No ha definido el grid que se va a llenar";
                return(false);
            }
            if (strSQL == "")
            {
                strError = "Debe definir una instrucción SQL";
                return(false);
            }

            clsConexion objConexionBd = new clsConexion();

            if (string.IsNullOrEmpty(strNombreTabla))
            {
                strNombreTabla = "Tabla";
            }
            objConexionBd.NombreTabla     = strNombreTabla;
            objConexionBd.StoredProcedure = StoredProcedure;
            objConexionBd.oCommand        = oCommand;
            objConexionBd.SQL             = strSQL;

            if (objConexionBd.LlenarDataSet())
            {
                grdGenerico.DataSource = objConexionBd.DATASET.Tables[strNombreTabla];
                grdGenerico.DataBind();
                objConexionBd.CerrarConexion();
                objConexionBd = null;
                return(true);
            }
            else
            {
                strError = objConexionBd.Error;
                objConexionBd.CerrarConexion();
                objConexionBd = null;
                return(false);
            }
        }
Пример #8
0
        public bool LlenarComboWeb()
        {
            if (Validar())
            {
                if (objcboGenericoWeb == null)
                {
                    strError = "No definió el combo";
                    return(false);
                }
                clsConexion objConexionBD = new clsConexion();

                objConexionBD.NombreTabla     = strNombreTabla;
                objConexionBD.StoredProcedure = StoredProcedure;
                objConexionBD.SQL             = strSQL;
                objConexionBD.oCommand        = oCommand;
                if (objConexionBD.LlenarDataSet())
                {
                    objcboGenericoWeb.DataSource     = objConexionBD.DATASET.Tables[strNombreTabla];
                    objcboGenericoWeb.DataTextField  = strColumnaTexto;
                    objcboGenericoWeb.DataValueField = strColumnaValor;
                    objcboGenericoWeb.DataBind();
                    objConexionBD.CerrarConexion();
                    objConexionBD = null;
                    return(true);
                }
                else
                {
                    strError = objConexionBD.Error;

                    objConexionBD.CerrarConexion();
                    objConexionBD = null;
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        public bool Consultar()
        {
            SQL = "SELECT USUARIO, ROL " +
                  " FROM dbo.TBL_LOGIN " +
                  " WHERE(USUARIO = @prUsuario) AND (CONTRASEÑA = @prContraseña)";


            //SQL = "SELECT USUARIO, CONTRASEÑA, ROL " +
            //    " FROM dbo.TBL_LOGIN " +
            //    " WHERE(USUARIO = '" + Usuario + ")AND (CONTRASEÑA = " + Contraseña + ")'";

            /* SQL = "SELECT   strNombre_CLIE, strPrimerApellido_CLIE, " +
             *              "strSegundoApellido_CLIE, strDireccion_CLIE " +
             *     "FROM     tblCliente " +
             *     "WHERE    strDocumento_CLIE = @prDocumento";*/

            clsConexion oConexion = new clsConexion();

            oConexion.SQL = SQL;
            oConexion.AgregarParametro("@prUsuario", Usuario);
            oConexion.AgregarParametro("@prContraseña", Contraseña);
            //Se invoca el método consultar
            if (oConexion.Consultar())
            {
                //Se verifica si hay datos
                if (oConexion.Reader.HasRows)
                {
                    //Tiene filas, se debe leer la información
                    oConexion.Reader.Read();
                    //Se captura la información
                    //idCliente = oConexion.Reader.GetInt32(0);
                    //Nombre_Completo = oConexion.Reader.GetString(1);
                    //Documento = oConexion.Reader.GetInt32(2);
                    //Telefono = oConexion.Reader.GetInt32(3);
                    Usuario = oConexion.Reader.GetString(0);
                    Rol     = oConexion.Reader.GetString(1);


                    //Libera memoria
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(true);
                }
                else
                {
                    //No tiene filas, se levanta un error
                    Error = "El usuario " + Usuario +
                            " no está en la base de datos. \nVerifique la información " +
                            "o ingréselo al sistema";
                    //Cerrar la conexión
                    oConexion.CerrarConexion();
                    oConexion = null;
                    return(false);
                }
            }
            else
            {
                Error = oConexion.Error;
                //Se debe cerrar la conexión
                oConexion.CerrarConexion();
                oConexion = null;
                return(false);
            }
        }