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); } }
public bool Consultar() { if (string.IsNullOrEmpty(strDocumento)) { strError = "No definió el documento del empleado"; return(false); } clsConexion oConexion = new clsConexion(); strSQL = "SELECT strNombre_EMPL, strPrimerApellido_EMPL, " + "strSegundoApellido_EMPL, strDireccion_EMPL, " + "strTelefono_EMPL " + "FROM Empleado " + "WHERE strDocumento_EMPL = '" + strDocumento + "'"; //Se debe pasar la propiedad SQL al objeto conexion oConexion.SQL = strSQL; //Se invoca el método de consultar de la clase conexión if (oConexion.Consultar()) { //Verificar si hay datos if (oConexion.Reader.HasRows) { //Hay que invocar el método Read oConexion.Reader.Read(); strNombre = oConexion.Reader.GetString(0); strPrimerApellido = oConexion.Reader.GetString(1); strSegundoApellido = oConexion.Reader.GetString(2); strDireccion = oConexion.Reader.GetString(3); strTelefono = oConexion.Reader.GetString(4); oConexion = null; return(true); } else { //No hay datos, se debe generar un mensaje de error strError = "El documento del empleado no existe en la base de datos"; oConexion = null; return(false); } } else { //Hubo un error al consultar, se lee el error, se libera memoria y se retorna strError = oConexion.Error; oConexion = null; return(false); } }
public bool Consultar() { if (iCodigo == 0) { strError = "No definió el código de la cabaña"; return(false); } clsConexion oConexion = new clsConexion(); strSQL = "SELECT [IdCabaña] " + ",[IdServicio]" + ",[IdTarifa]" + ",[IdImplementos]" + ",[Descripcion]" + ",[Nombre]" + "FROM [DBHosteria_Tesoro].[dbo].[Cabaña]" + "WHERE [IdCabaña] = " + iCodigo + ""; //Se debe pasar la propiedad SQL al objeto conexion oConexion.SQL = strSQL; //Se invoca el método de consultar de la clase conexión if (oConexion.Consultar()) { //Verificar si hay datos if (oConexion.Reader.HasRows) { //Hay que invocar el método Read oConexion.Reader.Read(); strNombre = oConexion.Reader.GetString(4); strDescripción = oConexion.Reader.GetString(5); oConexion = null; return(true); } else { //No hay datos, se debe generar un mensaje de error strError = "El documento del empleado no existe en la base de datos"; oConexion = null; return(false); } } else { //Hubo un error al consultar, se lee el error, se libera memoria y se retorna strError = oConexion.Error; oConexion = null; return(false); } }
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); } }
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); } }
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); } }
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); } }
public bool Consultar() { if (string.IsNullOrEmpty(strDocumento)) { strError = "No definió el documento del cliente"; return(false); } strSQL = "SELECT strNombre_CLIE, strPrimerApellido_CLIE, strSegundoApellido_CLIE " + "FROM Cliente " + "WHERE strDocumento_CLIE = '" + strDocumento + "'"; clsConexion oConexion = new clsConexion(); oConexion.SQL = strSQL; if (oConexion.Consultar()) { if (oConexion.Reader.HasRows) { oConexion.Reader.Read(); strNombre = oConexion.Reader.GetString(0); strPrimerApellido = oConexion.Reader.GetString(1); strSegundoApellido = oConexion.Reader.GetString(2); oConexion = null; return(true); } else { strError = "No hay datos de cliente para el documento seleccionado"; oConexion = null; return(false); } } else { strError = oConexion.Error; oConexion = null; return(false); } }
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); } }
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); } }