Exemple #1
0
        public bool UsuarioValido(string user, string pass)
        {
            bool   ret = false;
            string sql = $@"SELECT ID
                               FROM usuario
                               WHERE nome = '{user}'
                                 AND senha = '{pass}';";

            My.ExecuteReader(sql);

            if (My.HasRows())
            {
                ret = true;
            }

            My.FechaConexao();
            return(ret);
        }
        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);
        }
        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);
        }