示例#1
0
        public DataTable GetDataTable()
        {
            DataTable dt = new DataTable();

            string sql = "SELECT id, nome, tipo FROM usuario;";

            dt = My.GetDataTable(sql);

            My.FechaConexao();
            return(dt);
        }
        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 DataTable GetTable(int id = 0)
        {
            DataTable dt = new DataTable();

            string sql = $@"SELECT g.id AS id
                                 , CONCAT(m.graduacao, ' ', m.nome) AS nome
                                 , g.motivo AS motivo
                                 , g.saida AS saida
                                 , g.retorno AS retorno

                               FROM gerenciamento AS g
                               INNER JOIN militar AS m
                                  ON g.id_militar = m.id";

            if (id != 0)
            {
                sql += $" WHERE m.id = {id};";
            }

            dt = My.GetDataTable(sql);

            My.FechaConexao();
            return(dt);
        }