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 DTOMilitar GetDTO(string id) { DTOMilitar dto = new DTOMilitar(); string sql = $@"SELECT * FROM MILITAR WHERE id = {id} ORDER BY id DESC LIMIT 1;"; My.ExecuteReader(sql); if (My.HasRows()) { My.ReadNextRecord(); dto.Id = My.GetInt("id"); dto.Graduacao = My.GetString("graduacao"); dto.Nome = My.GetString("nome"); } My.FechaConexao(); return(dto); }
public ArrayList GetRelatorio(DateTime inicio, DateTime fim) { ArrayList array = new ArrayList(); string sql = $@"SELECT * FROM GERENCIAMENTO WHERE saida >= '{inicio.ToString("yyyy-MM-dd")}' AND saida <= '{fim.ToString("yyyy-MM-dd")} 23:59:59';"; My.ExecuteReader(sql); if (My.HasRows()) { while (My.ReadNextRecord()) { DTOGerenciamento dto = new DTOGerenciamento(); dto.Motivo = My.GetString("motivo"); dto.Saida = DateTime.ParseExact(My.GetString("saida"), "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); string retorno = My.GetString("retorno"); if (!string.IsNullOrEmpty(retorno)) { dto.Retorno = DateTime.ParseExact(My.GetString("retorno"), "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } Militar militar = new Militar(); dto.DTOMilitar = militar.GetDTO(My.GetString("id_militar")); array.Add(dto); } } My.FechaConexao(); return(array); }