public int buscarNombre() { List <SqlParameter> listaParametros = new List <SqlParameter>(); SqlConnector.agregarParametro(listaParametros, "@nombre", this.valor); SqlDataReader lector = SqlConnector.ejecutarReader("SELECT IdUsuario, Nombre, Apellido FROM PalcoNet.Cliente WHERE Nombre = @nombre", listaParametros, SqlConnector.iniciarConexion()); int cantRes = 0; if (lector.HasRows) { while (lector.Read()) { int IdUsuario = Convert.ToInt32(lector["IdUsuario"]); string Nombre = Convert.ToString(lector["Nombre"]); string Apellido = Convert.ToString(lector["Apellido"]); ResultadoClientes resultado = new ResultadoClientes(IdUsuario, Nombre, Apellido); resultados.Add(resultado); } } SqlConnector.cerrarConexion(); return(cantRes); }
public ResultadoClientes InsertarCliente(string apellido, string nombre, int idTipoDoc, int numeroDoc, int idSexo, string fechaNacimiento, string email, int telefono, string calle, int numeroCalle, int idLocalidad) { string sql_insert = ""; GestorTransaccionesSQL gestor = new GestorTransaccionesSQL(); ResultadoClientes resultado = new ResultadoClientes(); sql_insert = @"INSERT INTO Cliente VALUES ('" + apellido + "'," + " '" + nombre + "'," + " " + idTipoDoc + "," + " " + numeroDoc + "," + " " + idSexo + "," + " '" + fechaNacimiento + "'," + " '" + email + "'," + " " + telefono + "," + " '" + calle + "', " + " " + numeroCalle + "," + " " + idLocalidad + ")"; if (gestor.Insertar(sql_insert) == GestorTransaccionesSQL.ResultadoTransaccion.correcto) { mensajeRetorno = "Se cargaron correctamente los datos"; resultado = ResultadoClientes.correcto; } else { mensajeRetorno = "NO se cargaron correctamente los datos debido a: " + gestor.mensajeErrorTransaccion; resultado = ResultadoClientes.error; } return(resultado); }
public ResultadoClientes ModificarCliente(int idCliente, string apellido, string nombre, int idTipoDoc, int numeroDoc, int idSexo, string fechaNacimiento, string email, int telefono, string calle, int numeroCalle, int idLocalidad) { string sql_modificar = ""; sql_modificar = @"UPDATE Cliente SET Apellido = '" + apellido + "'," + " Nombre = '" + nombre + "'," + " IdTipoDocumento = " + idTipoDoc + "," + " NumeroDocumento = " + numeroDoc + "," + " IdSexo = " + idSexo + "," + " FechaNacimiento = '" + fechaNacimiento + "'," + " Email = '" + email + "'," + " Telefono = " + telefono + "," + " Calle = '" + calle + "'," + " NumeroCalle = " + numeroCalle + "," + " IdLocalidad = " + idLocalidad + " WHERE IdCliente = " + idCliente; GestorTransaccionesSQL gestor = new GestorTransaccionesSQL(); ResultadoClientes resultado = new ResultadoClientes(); if (gestor.Insertar(sql_modificar) == GestorTransaccionesSQL.ResultadoTransaccion.correcto) { mensajeRetorno = "Se cargaron correctamente los datos"; resultado = ResultadoClientes.correcto; } else { mensajeRetorno = "NO se cargaron correctamente los datos debido a: " + gestor.mensajeErrorTransaccion; resultado = ResultadoClientes.error; } return(resultado); }
public ResultadoClientes ConsultarClientesFiltros(string nombre, string apellido, string tipoDoc, string numeroDoc) { GestorTransaccionesSQL gestor = new GestorTransaccionesSQL(); ResultadoClientes resultado = new ResultadoClientes(); string sql = @"SELECT C.*, TD.Nombre, L.Nombre, S.Nombre FROM Cliente C JOIN TipoDocumento TD ON C.IdTipoDocumento = TD.IdTipoDocumento JOIN Localidad L ON C.IdLocalidad = L.IdLocalidad JOIN Sexo S ON C.IdSexo = S.IdSexo "; string where = @"WHERE "; if (nombre != "") { where = where + "C.Nombre like '%" + nombre + "%' AND "; } if (apellido != "") { where = where + "C.Apellido like '%" + apellido + "%' AND "; } if (tipoDoc != "0") { where = where + "C.IdTipoDocumento = " + tipoDoc + " AND "; } if (numeroDoc != "") { where = where + "C.NumeroDocumento = " + numeroDoc + " AND "; } int largoCadena = where.Length - 5; string whereFinal = ""; whereFinal = where.Substring(0, largoCadena); sql = sql + whereFinal; DataTable dt = new DataTable(); if (gestor.EjecutarConsulta(sql) == GestorTransaccionesSQL.ResultadoTransaccion.correcto) { tablaCliente = gestor.TablaResultado; resultado = ResultadoClientes.correcto; } else { mensajeRetorno = "No se consultaron correctamente los datos debido a: " + gestor.mensajeErrorTransaccion; resultado = ResultadoClientes.error; } return(resultado); }
public HttpResponseMessage PutChamado(int ChamadoId, Clientes clientes) { clientes.ChamadoId = ChamadoId; ResultadoClientes resultado = dao.AlterarChamado(clientes); if (resultado == ResultadoClientes.DESCRICAO_OK) { var response = Request.CreateResponse<Clientes>( HttpStatusCode.Created, clientes); string uri = Url.Link("DefaultApi", new { id = clientes.ChamadoId }); response.Headers.Location = new Uri(uri); return response; } else { string mensagem; switch (resultado) { case ResultadoClientes.CPF_INVALIDO: mensagem = "O CPF informado não existe"; break; case ResultadoClientes.CHAMADO_RESPONDIDO: mensagem = "Este chamado já foi respondido antes"; break; case ResultadoClientes.CHAMADO_NAO_REALIZADO: mensagem = "Impossível alterar: chamado não existe"; break; case ResultadoClientes.CHAMADO_EXCLUIDO: mensagem = "Impossível alterar: Este chamado foi excluido"; break; default: mensagem = "Ocorreu um erro inesperado"; break; } var erro = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Erro no servidor"), ReasonPhrase = mensagem }; throw new HttpResponseException(erro); } }
public ResultadoClientes EliminarCliente(int IdCliente) { string sql_delete = ""; sql_delete = @"DELETE FROM Cliente WHERE IdCliente = " + IdCliente; GestorTransaccionesSQL gestor = new GestorTransaccionesSQL(); ResultadoClientes resultado = new ResultadoClientes(); if (gestor.Eliminar(sql_delete) == GestorTransaccionesSQL.ResultadoTransaccion.correcto) { mensajeRetorno = "Se eliminaron correctamente los datos"; resultado = ResultadoClientes.correcto; } else { mensajeRetorno = "NO se eliminaron correctamente los datos debido a: " + gestor.mensajeErrorTransaccion; resultado = ResultadoClientes.error; } return(resultado); }
public ResultadoClientes ConsultarClientes() { GestorTransaccionesSQL gestor = new GestorTransaccionesSQL(); ResultadoClientes resultado = new ResultadoClientes(); string sql = @"SELECT C.*, TD.Nombre, L.Nombre, S.Nombre FROM Cliente C JOIN TipoDocumento TD ON C.IdTipoDocumento = TD.IdTipoDocumento JOIN Localidad L ON C.IdLocalidad = L.IdLocalidad JOIN Sexo S ON C.IdSexo = S.IdSexo"; if (gestor.EjecutarConsulta(sql) == GestorTransaccionesSQL.ResultadoTransaccion.correcto) { tablaCliente = gestor.TablaResultado; resultado = ResultadoClientes.correcto; } else { mensajeRetorno = "No se consultaron correctamente los datos debido a: " + gestor.mensajeErrorTransaccion; resultado = ResultadoClientes.error; } return(resultado); }
public int buscarApellido() { List<SqlParameter> listaParametros = new List<SqlParameter>(); BDSQL.agregarParametro(listaParametros, "@Apellido", this.valor); SqlDataReader lector = BDSQL.ejecutarReader("SELECT ID_User, Nombre, Apellido FROM MERCADONEGRO.Clientes WHERE Apellido = @Apellido", listaParametros, BDSQL.iniciarConexion()); int cantRes = 0; if (lector.HasRows) { while (lector.Read()) { int ID_User = Convert.ToInt32(lector["ID_User"]); string Nombre = Convert.ToString(lector["Nombre"]); string Apellido = Convert.ToString(lector["Apellido"]); ResultadoClientes resultado = new ResultadoClientes(ID_User, Nombre, Apellido); resultados.Add(resultado); } } BDSQL.cerrarConexion(); return cantRes; }
public HttpResponseMessage PostChamado(Clientes clientes) { ResultadoClientes resultado = dao.EfetuarChamado(clientes); if (resultado == ResultadoClientes.DESCRICAO_OK) { var response = Request.CreateResponse<Clientes>( HttpStatusCode.Created, clientes); string uri = Url.Link("DefaultApi", new { id = clientes.ChamadoId }); response.Headers.Location = new Uri(uri); return response; } else { string mensagem; switch (resultado) { case ResultadoClientes.CPF_INVALIDO: mensagem = "O CPF informado não existe"; break; default: mensagem = "Ocorreu um erro inesperado"; break; } var erro = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Erro no servidor"), ReasonPhrase = mensagem }; throw new HttpResponseException(erro); } }