public DTOUsuario GetDTO(string user, string pass) { DTOUsuario dto = new DTOUsuario(); if (UsuarioValido(user, pass)) { string sql = $@"SELECT * FROM usuario WHERE nome = '{user}' AND senha = '{pass}';"; My.ExecuteReader(sql); if (My.HasRows()) { My.ReadNextRecord(); dto.Id = My.GetInt("id"); dto.Nome = My.GetString("nome"); dto.Tipo = My.GetInt("tipo"); dto.Senha = My.GetString("senha"); } My.FechaConexao(); } else { dto = null; } return(dto); }
public DTOGerenciamento GetDTO(string id) { DTOGerenciamento dto = new DTOGerenciamento(); string sql = $@"SELECT * FROM GERENCIAMENTO WHERE id = {id};"; My.ExecuteReader(sql); if (My.HasRows()) { My.ReadNextRecord(); dto.Id = My.GetInt("id"); dto.IdMilitar = My.GetInt("id_militar"); dto.Motivo = My.GetString("motivo"); dto.Saida = DateTime.ParseExact(My.GetString("saida"), "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); dto.Retorno = DateTime.ParseExact(My.GetString("retorno"), "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } My.FechaConexao(); return(dto); }
public int GetIdByName(string nome) { int id = 0; string sql = $@"SELECT id FROM MILITAR WHERE CONCAT(graduacao, ' ', nome) = '{nome}' ORDER BY id DESC LIMIT 1;"; My.ExecuteReader(sql); if (My.HasRows()) { My.ReadNextRecord(); id = My.GetInt("id"); } My.FechaConexao(); return(id); }